My subplot images are cut off, why?

2 Ansichten (letzte 30 Tage)
Leandro de Oliveira
Leandro de Oliveira am 2 Sep. 2019
My images gets cut off when the function is on steady state, I think the problem comes from step command, because I'm getting [y, t] = step(sys)
informations and I don't know why this cut off automatically when a plot inside a subplot!
clc
clear all
syms s;
format short
%-------------------------------------------------------------------------%
% I)
wn1 = 1; k1 = [0 0 5]; zeta1 = [1.5, 0.7, 0.3];
G1 = tf(k1, [1 2*zeta1(1)*wn1 wn1^2]);
G2 = tf(k1, [1 2*zeta1(2)*wn1 wn1^2]);
G3 = tf(k1, [1 2*zeta1(3)*wn1 wn1^2]);
%-------------------------------------------------------------------------%
% II)
wn2 = 10; k2 = [0 0 5]; zeta2 = [1.5, 0.7, 0.3];
G4 = tf(k2, [1 2*zeta2(1)*wn2 wn2^2]);
G5 = tf(k2, [1 2*zeta2(2)*wn2 wn2^2]);
G6 = tf(k2, [1 2*zeta2(3)*wn2 wn2^2]);
%-------------------------------------------------------------------------%
lw = 3; %linewidth
ax1 = subplot(2,1,1); %i
hold on
[a,b] = step(G1);
plot(b, squeeze(a), 'LineWidth', lw, 'Color', 'r');
[a1,b1] = step(G2);
plot(b1, squeeze(a1), 'LineWidth', lw, 'Color', 'g');
[a2,b2] = step(G3);
plot(b2, squeeze(a2), 'LineWidth', lw, 'Color', 'b');
hold off
grid on
ax2 = subplot(2,1,2); %ii
hold on
[a3,b3] = step(G4);
plot(b3, squeeze(a3), 'LineWidth', lw, 'Color', 'r');
[a4,b4] = step(G5);
plot(b4, squeeze(a4), 'LineWidth', lw, 'Color', 'g');
[a5,b5] = step(G6);
plot(b5, squeeze(a5), 'LineWidth', lw, 'Color', 'b');
hold off
grid on
untitled.jpg

Akzeptierte Antwort

Leandro de Oliveira
Leandro de Oliveira am 2 Sep. 2019
SOLVED!
Actually is a simple thing, when whe plot getting step parameters we have to tell step xlim that we want the Tfinal, otherwise the step will automatically choose xlim as the stead state (I guess), so the correct way to get step parameter before plot is:
G = sys
[y, t] = step(sys, Tfinal) %Tfinal here commands plot xlim final value (higher hierarchy)
plot(t, squeeze(y))
xlim([0 Tfinal])

Weitere Antworten (0)

Kategorien

Mehr zu Line Plots finden Sie in Help Center und File Exchange

Produkte


Version

R2013b

Community Treasure Hunt

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

Start Hunting!

Translated by