필터 지우기
필터 지우기

simulate State Space system with lsim

조회 수: 18 (최근 30일)
Anthony Sirico
Anthony Sirico 2021년 2월 4일
답변: Star Strider 2021년 2월 4일
A = [0 1 0 0; 0 0 1 0; 0 0 0 1; -2 -5 -7 -2];
B = [0; 0; 0; 1];
C = [1 3 0 0];
D = 0;
t = 10;
sys = ss(A,B,C,D);
x0 = [1 1 1 1];
u = exp(-0.3*t)*sin(t);
lsim(sys, u, t)
grid
I was given this ss system, but it keeps returning:
Error using DynamicSystem/lsim (line 97)
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.
Error in HW2_2b (line 15)
lsim(sys, u, t)
Any ideas?

채택된 답변

Star Strider
Star Strider 2021년 2월 4일
For a SISO system, ‘t’ needs to be a vector:
t = linspace(0,10);
the full code being:
A = [0 1 0 0; 0 0 1 0; 0 0 0 1; -2 -5 -7 -2];
B = [0; 0; 0; 1];
C = [1 3 0 0];
D = 0;
t = linspace(0,10);
sys = ss(A,B,C,D);
x0 = [1 1 1 1];
u = exp(-0.3*t).*sin(2*pi*t);
lsim(sys, u, t)
grid
Create ‘t’ to be whatever you want.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Time and Frequency Domain Analysis에 대해 자세히 알아보기

제품


릴리스

R2020b

Community Treasure Hunt

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

Start Hunting!

Translated by