How can I save the elements into a List with a For Loop
5 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
Gözde Üstün
el 8 de Jul. de 2020
Respondida: madhan ravi
el 8 de Jul. de 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 comentarios
Respuesta aceptada
madhan ravi
el 8 de Jul. de 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 comentarios
Más respuestas (0)
Ver también
Categorías
Más información sobre Matrices and Arrays en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!