Suppose I want to solve
f = @(t,x) [-x(1)*x(2);x(1)*x(2)-x(2);x(2)]
[t,xa]=ode45(f,[0 6], [4 0.1 0]);
Now I want to present t like
t=0:0.001:6
How can I do this?

 採用された回答

Star Strider
Star Strider 2020 年 4 月 26 日

0 投票

Use your ‘t’ vector as the ‘tspan’ argument:
f = @(t,x) [-x(1)*x(2);x(1)*x(2)-x(2);x(2)];
t=0:0.001:6;
[t,xa]=ode45(f,t, [4 0.1 0]);
figure
plot(t, xa)
grid
legend('x_1', 'x_2', 'x_3')
.

その他の回答 (0 件)

カテゴリ

ヘルプ センター および File Exchange で Programming についてさらに検索

製品

リリース

R2020a

タグ

質問済み:

2020 年 4 月 26 日

回答済み:

2020 年 4 月 26 日

Community Treasure Hunt

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

Start Hunting!

Translated by