Error using DynamicSystem/lsim

조회 수: 5 (최근 30일)
Sahithi Laxmi
Sahithi Laxmi 2022년 12월 7일
댓글: Star Strider 2022년 12월 7일
clc
% Define the matrices
A = [-1 2 ; 0 -3];
B = [1 ; 1];
C = [1 2];
D = 1;
% System TF
G = ss(A,B,C,D);
% Define the time vector
t = 0:0.1:10;
% Define u(t)
u = 1;
% Plot the response
figure;
lsim(G,u,t);
grid
This is my code and I'm getting the following error
Error using DynamicSystem/lsim
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.

채택된 답변

Star Strider
Star Strider 2022년 12월 7일
Instead of:
% Define u(t)
u = 1;
use:
% Define u(t)
u = ones(size(t,2),1);
Then, it works —
% clc
% Define the matrices
A = [-1 2 ; 0 -3];
B = [1 ; 1];
C = [1 2];
D = 1;
% System TF
G = ss(A,B,C,D)
G = A = x1 x2 x1 -1 2 x2 0 -3 B = u1 x1 1 x2 1 C = x1 x2 y1 1 2 D = u1 y1 1 Continuous-time state-space model.
% Define the time vector
t = 0:0.1:10;
% Define u(t)
u = ones(size(t,2),1);
% Plot the response
figure;
lsim(G,u,t);
grid
.
  댓글 수: 2
Sahithi Laxmi
Sahithi Laxmi 2022년 12월 7일
Thank you so much for your response!
Star Strider
Star Strider 2022년 12월 7일
As always, my pleasure!

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Programming에 대해 자세히 알아보기

제품

Community Treasure Hunt

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

Start Hunting!

Translated by