Issues in plotting two graphs in the same plot with hold on function

3 vues (au cours des 30 derniers jours)
Hi everybody, i have an issue in plotting the graph with hold on function. Here is the code:
clear all
close all
clc
s = tf('s');
%data
Gp = 4/(s*(-0.4*s-50));
Gs = 5;
Ga = 3;
Kd = 1;
Gf = 1/(Kd*Gs);
% requirement 8
zeta = (abs(log(0.08)))/(sqrt(pi^2+log(0.08)^2))
Tp_max = 1/(2*zeta*sqrt(1-zeta^2))
Sp_max = (2*zeta*sqrt(2+4*zeta^2+2*sqrt(1+8*zeta)))/(sqrt(1+8*zeta^2)+4*zeta^2-1)
% requirement 6
tr_wc = (1/(sqrt(1-zeta^2)))*(pi-acos(zeta))*(sqrt(sqrt(1+4*zeta^4)-2*zeta^2))
% requirement 7
ts_wc = (-log(0.05)/zeta)*(sqrt(sqrt(1+4*zeta^4)-2*zeta^2))
%From the summary
Kc = 100;
nu = 1;
% Design of the controller
Lin = Kc/(s^nu)*Gp*Ga*Gs*Gf
%Bode plot
% figure(2)
% bode(Lin)
% figure(3)
% [num_Lin,den_Lin]=tfdata(Lin,'v');
% nyquist1(num_Lin,den_Lin)
%plot of the forbidden region
figure(4)
myngridst(Tp_max,Sp_max)
zoom on, hold on
nichols(Lin)
I have problems in figure 4 (myngridst is a function provided by the teacher to plot the forbidden region in loop shaping design). In particular, when i run the same code but written few months ago, it works correctly; instead, if i write a new code or i modify the code written some months ago i have these problems:
Instead i should have something like this:
Thank you in advance.
  6 commentaires
Cris LaPierre
Cris LaPierre le 18 Août 2021
Thanks. You can accept your own answer, and by so doing, indicate to others that this question has a solution.

Connectez-vous pour commenter.

Réponse acceptée

Bjorn Gustavsson
Bjorn Gustavsson le 18 Août 2021
In the screenshot matlab creates a new figure and makes the second plot in that figure, in the second you don't create the second figure and have both plots in the same figure.

Plus de réponses (0)

Catégories

En savoir plus sur Creating, Deleting, and Querying Graphics Objects dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by