How to add Cartesian grid in pzplot plot ?

6 vues (au cours des 30 derniers jours)
Devansh Tanna
Devansh Tanna le 13 Avr 2021
Commenté : Devansh Tanna le 16 Avr 2021
Is there any option to add Cartesian Grid in pzplot(sys) ?
I tried by adding following code
s = tf('s');
sys = (s+2.5)*(s-2)/(s+5)/(s+8-2i);
figure;
ax = gca;
ax.XGrid = 'on';
ax.YGrid = 'on';
h = pzplot(ax, sys);
p = getoptions(h);
p.XLim = {[-10, 4]};
p.YLim = {[-2.5, 2.5]};
setoptions(h, p);
but it did'n change plot generated by pzplot
when I add p.XGrid = 'on'; p.YGrid = 'on', it only shows zeta-wn grid.
PS : I was able to add Cartesian Grid by editing Edit -> Figure Properties but I wanted to do this by Code

Réponse acceptée

Monisha Nalluru
Monisha Nalluru le 16 Avr 2021
The reason for above issue is, pzplot clear the axes properties and plot the data into axes in required format.
This is the reason why the cartesian grid is removed once the pzplot is rendered on the figure.
Inorder to over come this issue, add the grid to axes after the pzplot.
As an example
s = tf('s');
sys = (s+2.5)*(s-2)/(s+5)/(s+8-2i);
figure;
h = pzplot(sys);
% set grid layout on axes after pzplot
ax =gca;
ax.XGrid = 'on';
ax.YGrid = 'on';
p = getoptions(h);
p.XLim = {[-10, 4]};
p.YLim = {[-2.5, 2.5]};
setoptions(h, p);
  1 commentaire
Devansh Tanna
Devansh Tanna le 16 Avr 2021
Thanks !! It worked ....

Connectez-vous pour commenter.

Plus de réponses (0)

Community Treasure Hunt

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

Start Hunting!

Translated by