wrong outcomes when using lsim and step function

4 次查看(过去 30 天)
hello everyone,
I am trying to define a 2nd order system y''(t)+5y'(t)+6y(t)=15u(t) in the state space and get outcomes (y) for different incomes (u).
the initial conditions are y(0)=y'(0)=0.
u=const=2;
the analytical solution is y=5 -15*exp(-2t) +10*exp(-3t), so it's clear that yss, the steady state output, is 5.
but when using the lsim or even step functions I am getting strange results (yss=0.33). any idea what's wrong?
error.JPG
the code is:
clear all
close all
clc
syms t y(t) %creating symbolic variable
%defining the ODE that describes the physical behaviour of the system
a=[6,5,1]; %creating a vector that represents the Input function derivatives coefficients - [a0,a1,...,an-1,...,a0] - 6y+5y'+y''
b=[15,0,0]; %creating a vector that represents the Output function derivatives coefficients - [b0,b1,...,bn-1,...,b0] - 15u+0u'+0u''
ode_order=length(a)-1; %determines the system order
%creating the matrices of the space state y''=-(a1/a2)*y'-(a0/a2)*y+(b0/a0)*u
%X=[x1,x2]=[y,y'] and X'=[x1',x2']=[y',y'']=[x2,-(a0/a2)*x1-(a1/a2)*x2+(b0/a0)*u]
A=zeros(ode_order,ode_order);
for k=[1:1:(ode_order-1)]
A(k,k+1)=1;
end
for k=[1:1:ode_order]
A(ode_order,k)=-(a(k)/a(ode_order+1));
end
B=zeros(ode_order,1);
B(ode_order,1)=1;
C=zeros(1,ode_order);
C(1,1)=1;
D=zeros(1,1);
end
%DEFINING OUR SYSTEM IN TERMS OF STATE SPACE
sys=ss(A,B,C,D);
t2=[0:0.01:15];
u2=zeros(1,length(t2));
for counter=1:1:length(t2)
u2(counter)=2;
end
lsim(sys,u2,t2,[0,0])

回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Calculus 的更多信息

标签

产品


版本

R2018b

Community Treasure Hunt

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

Start Hunting!

Translated by