필터 지우기
필터 지우기

I'd like to make several 'figure' window

조회 수: 2 (최근 30일)
가현
가현 2024년 5월 22일
댓글: 가현 2024년 5월 22일
I want to add two figure windows, but <figure 2> window doesn't show up.
<code>
%상태 방정식
%Dx1 = -x1 - x2 + u1 + u2
%Dx2 = 6.5*x1 + u1
%y1 = x1
%y2 = x2
t = 0:0.01:15;
A = [-1 -1;6.5 0];
B = [1 1;1 0];
C = [1 0;0 1];
D = [0 0;0 0];
sys = ss(A,B,C,D);
impulse(sys,t);
[y,t,x] = impulse(sys,t);
y1 = [1 0]*y(:,:,1)' + [1 0]*y(:,:,2)';
y2 = [0 1]*y(:,:,1)' + [0 1]*y(:,:,2)';
figure(1)
plot(t,sys)
xlabel('Time,(s)')
ylabel('y')
grid;
legend('y')
figure(2)
subplot(211);
plot(t, y1); grid
ylabel('y_1')
subplot(212);
plot(t, y2); grid
xlabel('t (sec)'); ylabel('y_2')

채택된 답변

Infinite_king
Infinite_king 2024년 5월 22일
편집: Infinite_king 2024년 5월 22일
Hi 가현,
The following expression 'plot(t,sys)' will result in an error since 'sys' is a dynamic system model, and the 'plot' function will not accept a model as input. The line 'plot(t,sys)' can be removed because the 'impulse' function plots the impulse response of 'sys'
t = 0:0.01:15;
A = [-1 -1;6.5 0];
B = [1 1;1 0];
C = [1 0;0 1];
D = [0 0;0 0];
sys = ss(A,B,C,D);
impulse(sys,t); % this syntax will plot the impulse response
[y,t,x] = impulse(sys,t);
y1 = [1 0]*y(:,:,1)' + [1 0]*y(:,:,2)';
y2 = [0 1]*y(:,:,1)' + [0 1]*y(:,:,2)';
figure(1)
% plot(t,sys)
xlabel('Time,(s)')
ylabel('y')
grid;
legend('y')
figure(2)
subplot(211);
plot(t, y1); grid
ylabel('y_1')
subplot(212);
plot(t, y2); grid
xlabel('t (sec)'); ylabel('y_2')
For more information on 'impulse' function, refer the following MATLAB documentation - https://www.mathworks.com/help/ident/ref/dynamicsystem.impulse.html
  댓글 수: 1
가현
가현 2024년 5월 22일
Thank you for your kind reply. This helped me solve my problem!

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

추가 답변 (0개)

태그

제품


릴리스

R2024a

Community Treasure Hunt

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

Start Hunting!

Translated by