Save each loop values, without overwriting

7 vues (au cours des 30 derniers jours)
Ajay Kumar
Ajay Kumar le 25 Jan 2019
How can I save each loop values without overwriting

Réponse acceptée

KALYAN ACHARJYA
KALYAN ACHARJYA le 25 Jan 2019
Modifié(e) : KALYAN ACHARJYA le 25 Jan 2019
for i=1:10
a(i)=..... %using array
end
Here value will not replace, values save as a(1), a(2).. etc
  3 commentaires
KALYAN ACHARJYA
KALYAN ACHARJYA le 18 Sep 2021
Chaudhary P Patel
Chaudhary P Patel le 7 Juin 2022
% I am facing the that Utt for n=5 replacing the others, so I am unable to call the previous value of Utt for n=1,2,3, and 4 .
for i=1:1:10
for n=1:1:5
if n==1
Utt(:,i+1)=([zeros(3,1); utdelt(1:3,i+1)]); % utdelt (15X10)
else
d1=1+(n-2)*3;
d2=6+(n-2)*3;
Utt(:,i+1)=utdelt(d1:d2,i+1);
end
end
end
% end of the loop Utt is only saved for n=5, how can i save all the value
% of Utt for n=1,2,3,4 also.

Connectez-vous pour commenter.

Plus de réponses (1)

madhan ravi
madhan ravi le 25 Jan 2019
https://www.mathworks.com/help/matlab/matlab_prog/preallocating-arrays.html - essential for a loop and see how the variables are indexed using loop iterator.
  2 commentaires
KALYAN ACHARJYA
KALYAN ACHARJYA le 25 Jan 2019
@madhan ravi Sir
Congratulations! MVP
madhan ravi
madhan ravi le 25 Jan 2019
Thank you!

Connectez-vous pour commenter.

Catégories

En savoir plus sur Startup and Shutdown dans Help Center et File Exchange

Tags

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by