MATLAB: Please help why is the lsim not plotting

dynamics modelingmechanical engineer

clear all
close all
syms s
A=[10*s^2+10*s+400 0 -200;0 20*s^2+10*s+400 -10*s-200;-200 -10*s-200 30*s^2+10*s+400];
B=[0;0;1];
sol=inv(A)*B
m1=(2*(2*s^2 + s + 40))/(6*s^6 + 11*s^5 + 445*s^4 + 440*s^3 + 8440*s^2 + 2400*s + 32000)
m2=((s + 20)*(s^2 + s + 40))/(10*(6*s^6 + 11*s^5 + 445*s^4 + 440*s^3 + 8440*s^2 + 2400*s + 32000))
m31=((2*s^2 + s + 40)*(s^2 + s + 40))/(10*(6*s^6 + 11*s^5 + 445*s^4 + 440*s^3 + 8440*s^2 + 2400*s + 32000))
m3=m1-m31
h=10/s
x1s=(m1*h)
x2s=(m2*h)
x3s=(m3*h)
[nums,dens]=numden(m1)
num=sym2poly(nums)
den=sym2poly(dens)
m1s=tf(num,den)
m1s=minreal(m1s)
[nums,dens]=numden(m2)
num2=sym2poly(nums)
den2=sym2poly(dens)
m2s=tf(num,den)
m2s=minreal(m2s)
[nums,dens]=numden(m3)
num3=sym2poly(nums)
den3=sym2poly(dens)
m3s=tf(num,den)
m3s=minreal(m3s)
[x1 t]=step(m1s,100)
[x2 t2]=step(m2s,100)
[x3 t3]=step(m3s,100)
figure(4)
subplot(311)
plot(t,x1)
subplot(312)
t=0:0.001:10
u=10
lsim(m1s,u*ones(length(t),1),t)
subplot(313)
impulse(m1s)
figure(5)
subplot(311)
plot(t2,x2)
subplot(312)
lsim(m2s,u*ones(length(t),1),t)
subplot(313)
impulse(m2s)
figure(6)
subplot(311)
plot(t3,x3)
subplot(312)
lsim(m3s,u*ones(length(t),1),t)
plot(t,y3)
subplot(313)
impulse(m3s)

Best Answer

Error using DynamicSystem/lsim (line 84)
When simulating the response to a specific input signal, the input data U must be a matrix of numeric values with at least two rows (samples) and without any NaN or Inf.
Your u matrix is the scalar 10.
"The input u is an array having as many rows as time samples (length(t)) and as many columns as system inputs. For instance, if sys is a SISO system, then u is a t-by-1 vector. If sys has three inputs, then u is a t-by-3 array. Each row u(i,:) specifies the input value(s) at the time sample t(i). The signal u also appears on the plot."
If you want to use the same value of u for all entries, then replicate it:
lsim(m1s, u * ones(length(t),1), t)