Filter löschen
Filter löschen

For Loop with matrices?

2 Ansichten (letzte 30 Tage)
Michela Longhi
Michela Longhi am 14 Mai 2019
Beantwortet: Star Strider am 14 Mai 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!!!!

Akzeptierte Antwort

Star Strider
Star Strider am 14 Mai 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.

Weitere Antworten (0)

Kategorien

Mehr zu Loops and Conditional Statements finden Sie in Help Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by