I have problem in solving ode45
1 view (last 30 days)
Show older comments
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.
0 Comments
Accepted Answer
Star Strider
on 3 Aug 2022
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);
plot(t, x(:,1));
Make appropriate changes to get the desired result.
.
2 Comments
More Answers (0)
See Also
Categories
Find more on Ordinary Differential Equations in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!