Borrar filtros
Borrar filtros

I'd like to make several 'figure' window

2 visualizaciones (últimos 30 días)
가현
가현 el 22 de Mayo de 2024
Comentada: 가현 el 22 de Mayo de 2024
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')

Respuesta aceptada

Infinite_king
Infinite_king el 22 de Mayo de 2024
Editada: Infinite_king el 22 de Mayo de 2024
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 comentario
가현
가현 el 22 de Mayo de 2024
Thank you for your kind reply. This helped me solve my problem!

Iniciar sesión para comentar.

Más respuestas (0)

Etiquetas

Productos


Versión

R2024a

Community Treasure Hunt

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

Start Hunting!

Translated by