Holding stepplot and pzplot in same loop

1 回表示 (過去 30 日間)
am
am 2021 年 2 月 12 日
回答済み: Reshma Nerella 2021 年 2 月 18 日
Hi,
I am unable to hold both stepplot and pzplot in this loop despite trying different answers in the forum.
Can someone help?
syms g s z w
w1 = 4
z1 = 0.5
getAllInfo(w1,z1)
w2 = 4
z2 = 0.3
getAllInfo(w2,z2)
w3 = 2
z3 = 0.5
getAllInfo(w3,z3)
w4 = 2
z4 = 0.3
getAllInfo(w4,z4)
function getAllInfo(w,z)
num = [w^2]
den = [1 2*z*w w^2]
G = tf(num, den)
stepplot(G);
ax1 = axes ;
hold(ax1,'on')
figure()
pzplot(G);
ax2 = axes ;
hold(ax2,'on')
end

採用された回答

Reshma Nerella
Reshma Nerella 2021 年 2 月 18 日
Hi,
One solution might be creating axes outside the function and pass them as parameters to the function.
Use hold on and plot on required axes.
For instance
f1 = figure;
ax1 = axes(f1) ;
f2 = figure;
ax2 = axes(f2) ;
hold(ax1,'on');
hold(ax2,'on');
syms g s z w
w1 = 4
z1 = 0.5
getAllInfo(w1,z1,ax1,ax2)
function getAllInfo(w,z,ax1,ax2)
num = [w^2]
den = [1 2*z*w w^2]
G = tf(num, den)
stepplot(ax1,G);
pzplot(ax2,G);
end
This will create all stepplots in one figure and pzplots in other one.
Hope this helps!

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeLabels and Annotations についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by