How to add Cartesian grid in pzplot plot ?

4 visualizaciones (últimos 30 días)
Devansh Tanna
Devansh Tanna el 13 de Abr. de 2021
Comentada: Devansh Tanna el 16 de Abr. de 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

Respuesta aceptada

Monisha Nalluru
Monisha Nalluru el 16 de Abr. de 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);

Más respuestas (0)

Categorías

Más información sobre Line Plots en Help Center y File Exchange.

Community Treasure Hunt

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

Start Hunting!

Translated by