I have problem in solving ode45

1 回表示 (過去 30 日間)
Dinesh Durai
Dinesh Durai 2022 年 8 月 3 日
コメント済み: Star Strider 2022 年 8 月 6 日
clear all, close all, clc
w=2*pi;
zeta=0.25;
A=[0 1;-w^2 -zeta];
dt=0.01;
T=10;
x0=2;
[t,x] = ode45(@(t,x) A*x, 0:dt:T, x0);
plot(t, x(:,1));
i am getting error as
Error in ode45 (line 12)
[t,x] = ode45(@(t,x) A*x, 0:dt:T, x0);
i dont know what wrong i did here, if any body spoted out it will be very helful. Thank you.

採用された回答

Star Strider
Star Strider 2022 年 8 月 3 日
The principal problem appears to be having 2 differential equations and 1 initial condition.
Try this —
w=2*pi;
zeta=0.25;
A=[0 1;-w^2 -zeta];
dt=0.01;
T=10;
x0=[0 2]; % Add Second Initial Condition
[t,x] = ode45(@(t,x) A*x, 0:dt:T, x0);
t = 1001×1
0 0.0100 0.0200 0.0300 0.0400 0.0500 0.0600 0.0700 0.0800 0.0900
x = 1001×2
0 2.0000 0.0200 1.9911 0.0398 1.9743 0.0594 1.9498 0.0788 1.9177 0.0978 1.8781 0.1163 1.8312 0.1344 1.7772 0.1518 1.7163 0.1687 1.6488
plot(t, x(:,1));
Make appropriate changes to get the desired result.
.
  2 件のコメント
Dinesh Durai
Dinesh Durai 2022 年 8 月 6 日
Thank you
Star Strider
Star Strider 2022 年 8 月 6 日
As always, my pleasure!

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeOrdinary Differential Equations についてさらに検索

製品


リリース

R2022a

Community Treasure Hunt

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

Start Hunting!

Translated by