ode45 solver errors with time-dependant forcing/parameters
古いコメントを表示
Hi, I'm using a script below to apply a small time-dependant impulse force to a 2DOF spring-mass damper system.
I seem to be getting a lot of errors with my ode45 solver and was wondering if I could get some help? It's due in 2 days so I could really use some support.
Thanks!
function batch_timeresp
% the total time domain response
clear all
close all
clc;
% System parameters
k3 = 15; k1 = 10.0; k2 = 10.0; m1 = 1; m2 = 2; L = 1.0; c = 1; ct = 0.5; g = 9.81;kequi=5;
% Excitation parameters
tpulse=linspace(0,1,50);
Impulse = heaviside(tpulse-0)-heaviside(tpulse-0.1);
F_I=@(t)(interp1(tpulse,Impulse,t));
% State space system matrix and coupling
A=[0,0,1,0;0,0,0,1;-(k1+k2)/(m1+m2),0,-c/(m1+m2),0;0,-k3/(m1*(L^2)),0,-ct/(m1*(L^2))]; %state space matrix
S=[1,0,0,0;0,1,0,0;0,0,1,(1*L)/(m1+m2);0,0,(m1*L)/(m1*(L^2)),1]; %coupling
Sinv=inv(S);
Gmat = [0;0;-g;g/L]; %gravity terms
Fmat=@(tt) ([0;0;F_I(tt)/(m1+m2);(2*F_I(tt)*L)/(m1*(L^2))]); %impulse force
% Numerical integration
tspan=linspace(0,10,1e3);
X0=[0;0;0;0];
[TT,XX]=ode45(@(t,x) ssmodel(t,x,A,Gmat,Fmat(t),Sinv),tspan,X0);
%Plot Impulse
imp = F_I(tpulse);
figure;
plot(tpulse,imp,'b-');
% Results
hold on;
plot(TT,XX),
xlabel('time [s]')
legend('Impulse Force [N]','Block Dispalcement [m]','Ball Displacement [rad]','Block Velocity [m/s]','Ball Velocity [rad/s]')
function dx=ssmodel(t,x,A,Gmat,Fmat,Sinv)
% State-space model of 1 DOF system
dx=Sinv*(A*x+Gmat+Fmat(t)); %%%%%%%%%%%%%%%%%%%%%%
end
end
採用された回答
その他の回答 (0 件)
カテゴリ
ヘルプ センター および File Exchange で General Applications についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!