How to make a plot from for loop where the results are a 3x1 matrix?

7 ビュー (過去 30 日間)
Nikolai
Nikolai 2020 年 9 月 18 日
回答済み: Star Strider 2020 年 9 月 18 日
s=300
r=25
k=30
kukat=[s;r;k]
A=[0.23 0 233;0.74 0.52 0;0 0.35 0.46]
a=15
hold on
for x=1:a
maarat=A^x*kukat
end
So here is my for loop and my goal would be to create a plot where there would be three lines. One line would show the results of the first row of the 3x1 matrix. I've tried to look it up but my lack of english skills makes it hard.

採用された回答

Star Strider
Star Strider 2020 年 9 月 18 日
Try this slight variation on your code:
s=300;
r=25;
k=30;
kukat=[s;r;k];
A=[0.23 0 233;0.74 0.52 0;0 0.35 0.46];
a=15;
x=1:a;
for k = 1:numel(x)
maarat(:,k) = A^x(k)*kukat;
end
figure
semilogy(x, maarat)
grid
xlabel('x')
ylabel('maarat')
If you are simulating a control system, there are easier ways. If you want to do it yourself, use the expm function to create the matrix exponential.

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeLine Plots についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by