Store a variable in a loop

2 visualizzazioni (ultimi 30 giorni)
Rafael Freire
Rafael Freire il 6 Feb 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

Risposta accettata

Kevin Holst
Kevin Holst il 6 Feb 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]';

Più risposte (0)

Categorie

Scopri di più su Loops and Conditional Statements in Help Center e File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by