Clear Filters
Clear Filters

For Loop with matrices?

2 views (last 30 days)
Michela Longhi
Michela Longhi on 14 May 2019
Answered: Star Strider on 14 May 2019
Hello!
I have these matrices:
x(0)=[1;2] and x(1)=A*x(0), where A=[1 3;4 5]
How can I create a for lopp to obtain:
x(2)=A*x(1)
x(3)=A*x(2)
....
Thanks for your answers!!!!

Accepted Answer

Star Strider
Star Strider on 14 May 2019
One approach:
A=[1 3;4 5];
x(:,1)=[1;2];
N = 10;
for k = 1:N
x(:,k+1) = A*x(:,k);
end
You simply need to be careful to provide the correct indexing.
Experiment to get the result you want.

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!