How to add Cartesian grid in pzplot plot ?

조회 수: 6 (최근 30일)
Devansh Tanna
Devansh Tanna 2021년 4월 13일
댓글: Devansh Tanna 2021년 4월 16일
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

채택된 답변

Monisha Nalluru
Monisha Nalluru 2021년 4월 16일
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);

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Line Plots에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by