Store a variable in a loop

2 vues (au cours des 30 derniers jours)
Rafael Freire
Rafael Freire le 6 Fév 2012
How 1 store a variable in this loop
for i=[0 0.01 0.5 0.6 1 1.2 1.5]
stored(i, 1)=1+i
end
best regards

Réponse acceptée

Kevin Holst
Kevin Holst le 6 Fév 2012
how about something simple like this?
n = [0 0.01 0.5 0.6 1 1.2 1.5];
for i = 1:length(n)
stored(i,1) = 1 + n(i);
end
or just
stored = [0 0.01 0.5 0.6 1 1.2 1.5]';

Plus de réponses (0)

Catégories

En savoir plus sur Loops and Conditional Statements 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!

Translated by