How to save for loop data into vector

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.

 Accepted Answer

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

More Answers (0)

Categories

Find more on Loops and Conditional Statements in Help Center and File Exchange

Asked:

on 28 Nov 2014

Answered:

on 28 Nov 2014

Community Treasure Hunt

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

Start Hunting!