Multiple outputs from a for loop
Mostra commenti meno recenti
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 Commenti
Stephen23
il 21 Giu 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
il 21 Giu 2022
Already you have that in hand.
z(1), z(2),...z(n) etc.,
Roger Kalvig
il 21 Giu 2022
Risposta accettata
Più risposte (0)
Categorie
Scopri di più su Numerical Integration and Differentiation in Centro assistenza e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!

