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);
  1 件のコメント
Devansh Tanna
Devansh Tanna 2021 年 4 月 16 日
Thanks !! It worked ....

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeLine Plots についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by