i want to solve 1 dof differential equation by using ss and lsim for just as an example.
probrem is the result calculated by ss&lsim and the result calcuated by matmatically analitically caliculation are different.
do you know why this things happen? if my code has some mistake, I want to know where is prob.
Best,
hiroki
---code---
M=4;
C=0;
K=2500;
A=[0 1; -K/M -C/M];
B=[0;1/M];
C=[1 0];
D=0;
sys=ss(A,B,C,D)
dt=0.001;
t=dt*[1:100];
w=100;
f=2*cos(w*t);
u=f;
x=2/(K-M*w^2)*cos(w*t);
y = lsim(sys,u,t);
plot(t,u)
hold on
yyaxis right
plot(t,y)
hold on
yyaxis right
plot(t,x);
legend('u:input','y:sys solution','x: analitical solution')
0 Comments
Sign in to comment.