Borrar filtros
Borrar filtros

For Loop with matrices?

2 visualizaciones (últimos 30 días)
Michela Longhi
Michela Longhi el 14 de Mayo de 2019
Respondida: Star Strider el 14 de Mayo de 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!!!!

Respuesta aceptada

Star Strider
Star Strider el 14 de Mayo de 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.

Más respuestas (0)

Categorías

Más información sobre Loops and Conditional Statements en Help Center y File Exchange.

Community Treasure Hunt

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

Start Hunting!

Translated by