For Loop with matrices?

4 次查看(过去 30 天)
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!!!!

采纳的回答

Star Strider
Star Strider 2019-5-14
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.

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Loops and Conditional Statements 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by