How to save for loop data into vector

1 Ansicht (letzte 30 Tage)
Veronika
Veronika am 28 Nov. 2014
Beantwortet: Guillaume am 28 Nov. 2014
Dear all, I have this simple code:
for s = 0.0:0.1:1
disp(s)
end
I want to save data from this for loop into a vector. How can I do this?
Thank you for answers.

Akzeptierte Antwort

Guillaume
Guillaume am 28 Nov. 2014
v = 0:0.1:1 %?
Or if you really want to be inefficient and use a loop:
idx = 1;
for s = 0:0.1:1
v(idx) = s;
idx = idx + 1;
end

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