Store a variable in a loop

1 Ansicht (letzte 30 Tage)
Rafael Freire
Rafael Freire am 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

Akzeptierte Antwort

Kevin Holst
Kevin Holst am 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]';

Weitere Antworten (0)

Kategorien

Mehr zu Loops and Conditional Statements finden Sie in Help Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by