how to use ss and lsim for 1 dof differential equation
5 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
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 comentarios
Respuesta aceptada
Paul
el 1 de En. de 2021
That lsim command calculates y using default initial conditions x(0) = xdot(0) = 0, but the analytical solution clearly doesn't satisfy those initial conditions. It looks like that solution satisfies the initial conditions x(0) = 2/(K-M*w^2), xdot(0) = 0. Try this:
y1 = lsim(sys,u,t,[2/(K-M*w^2) 0]);
and compare to x and y.
Alos, why not define t starting from 0?
t = dt*[0:100]
Más respuestas (0)
Ver también
Categorías
Más información sobre Digital Filter Analysis en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!