How can I save the elements into a List with a For Loop
5 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
Gözde Üstün
le 8 Juil 2020
Réponse apportée : madhan ravi
le 8 Juil 2020
Hey,
I am trying to my results in a for loop but I can save just the last result How can I solve the problem?
function[ rho,gs,hs,k_value ]= plott(a,b)
numbers = [0.9,0.95,0.96,0.97,0.98,0.99,0.9977,0.9978,0.9979,0.998,0.999,1];
d = 2;
k_value=[];
rhos=[];
gs=[];
hs=[];
for i=length(numbers)
a=noise(i);
rho = dep(d,noise(i));
P=Pr(alice,bob,rho);
[G,B,rho]=T(P,a,b);
H=H_(P(:,:,1,1))
K=-log2(G)-H;
k_value(i)=[K];
hs(i)=[H];
gs(i)=[G];
rhos=[rho];
end
% k_value=[K];
% hs=[H];
% gs=[G];
% rhos=[rho];
end
0 commentaires
Réponse acceptée
madhan ravi
le 8 Juil 2020
function[ rho,gs,hs,k_value ]= plott(a,b)
numbers = [0.9,0.95,0.96,0.97,0.98,0.99,0.9977,0.9978,0.9979,0.998,0.999,1];
d = 2;
[k_value,rhos,gs,hs] = deal(zeros(numel(numbers),1));
for ii = 1 : numel(numbers)
a=noise(ii);
rho = dep(d,noise(ii));
P=Pr(alice,bob,rho);
[G,B,rho]=T(P,alice,bob);
H=H_(P(:,:,1,1))
K=-log2(G)-H;
k_value(ii)= K;
hs(ii)= H;
gs(ii)= G;
rhos(ii) =rho;
end
end
0 commentaires
Plus de réponses (0)
Voir également
Catégories
En savoir plus sur Matrices and Arrays dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!