Multiple outputs from a for loop
Show older comments
Basic problem, but I can't find the solution:
consider basic a for loop:
for i = 1:5
z(i)=3*i
end
It produces a vector z= [3 6 9 12 15]. What I need is all the components of the vector z as a sperate variables(scalars), let,s say
z1=3, z2=6 and so on. How can I do that?
Thanks in advance
Roger Kalvig
4 Comments
Stephen23
on 21 Jun 2022
"What I need is all the components of the vector z as a sperate variables(scalars)"
Why?
What do you imagine that you can do with lots of scalars, that is not possible using indexing?
"say z1=3, z2=6 and so on."
KSSV
on 21 Jun 2022
Already you have that in hand.
z(1), z(2),...z(n) etc.,
Roger Kalvig
on 21 Jun 2022
Accepted Answer
More Answers (0)
Categories
Find more on Numerical Integration and Differentiation in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!
