Need Help Solving a system of 2nd and 1st Order ODEs

1 次查看(过去 30 天)
I have three differenital equations modeling a suspension system
Variables are Xu, Xs, X3 while Xo is an input that is generated by a white noise. Everything else is a constant
I have been trying to solve it for some time now but for some reason the solutions are always either zero or completely wrong.
Any help would be greatly appreciated as I have only just started using MATLAB.
Here is my code:
function dy = mysys(t,y,T,Xo)
format long
Xo = interp1(T,Xo,t);
k1 = 15000; k2 = 15000; kt = 200000; c1 = 1000; c2 = 1000; Ms=300; Mu=40;
dy(1) = y(4);
dy(2) = y(5);
dy(3) = y(6);
dy(4) = ((k1/Ms)*(y(2)-y(3)) + (c1/Ms)*(y(5)-y(4)));
dy(3) = (y(5) - (k2/c2)*(y(3)-y(1)) - (k2/c2)*(y(2)-y(3)))
dy(6) = ((kt/Mu)*(Xo-y(2)) - (c1/Mu)*(y(5)-y(4)) - (c2/Mu)*(y(5)-y(6)) - (k2/Mu)*(y(2)-y(3)));
dy = dy(:);
timerange = [0 10];
y0 = [0 0 0 0 0 0];
T = road_xo_time.Time;
Xo = road_xo_time.Data;
[t,y] = ode45(@(t,y) mysys(t,y,T,Xo), timerange, init_cond);
plot(t, y(:,1))

采纳的回答

Alan Stevens
Alan Stevens 2020-12-27
I think you should be passing only 5, not 6, parameters to your mysys function, which is better written as
function dy = mysys(t,y,T,Xo)
Xo = interp1(T,Xo,t);
k1 = 15000; k2 = 15000; kt = 200000; c1 = 1000; c2 = 1000; Ms=300; Mu=40;
xs = y(1);
xu = y(2);
x3 = y(3);
vs = y(4);
vu = y(5);
v3 = vu - (k1/c2)*(x3 - xs) - (k2/c2)*(xu - x3);
dy = [vs; % dxs/dt
vu; % dxu/dt
v3; % dx3/dt
(k1/Ms)*(xu - x3) + (c1/Ms)*(vu - vs); % d2xs/dt2
(kt/Mu)*(X0 - xu) - (c1/Mu)*(vu - vs) - (c2/Mu)*(vu - v3) - (k2/Mu)*(xu - x3)]; % d2xu/dt2
end
You can, of course, use y's where I used x's.

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Statics and Dynamics 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by