how to store a vector that i got from a for loop ?

4 views (last 30 days)
i need put all results in the same vector, the vector A only show me the last result in the for loop
for i=1:3
a=[2+i,i]
d=[5+2*i, 3*i]
endfor
A=[a' d' ]

Accepted Answer

Sulaymon Eshkabilov
Sulaymon Eshkabilov on 23 Jun 2019
Hi,
Here is the solution to your loop based script to save all values:
for i=1:3
a(i, :)=[2+i,i]
d(i, :)=[5+2*i, 3*i]
end
A=[a' d' ]
Good luck.
  6 Comments
Sulaymon Eshkabilov
Sulaymon Eshkabilov on 23 Jun 2019
@ Sandra: but you didn't hit accept .. :) . Good luck.

Sign in to comment.

More Answers (0)

Categories

Find more on Loops and Conditional Statements 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!