How to add Cartesian grid in pzplot plot ?

6 visualizzazioni (ultimi 30 giorni)
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

Risposta accettata

Monisha Nalluru
Monisha Nalluru il 16 Apr 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);

Più risposte (0)

Community Treasure Hunt

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

Start Hunting!

Translated by