Matrix convulsion in the x,y plane with intersections

1 次查看(过去 30 天)
Hello all. I need help regarding the intersection point between a freqs plot and yline plotted on the same plot. How can I go about doing this? I'll leave a portion of the code below,
[b,a] = butter(8,[omegac1 omegac2],'bandpass','s');
figure; freqs(b,a) Gp=0.8881779763; yline(Gp,'Gp');
I need the intersection point (x,y) between yline(gp) and the freqs figure from above. I'd appreciate any help. Thanks in advance.
  2 个评论
Star Strider
Star Strider 2021-10-29
@USER SEEF — Please do not eliminate the question, especially after someone has gone through the trouble of posting an Answer.
The question text had to do with determining the frequency at which a transfer function intersected a yline at 9.68. This is similar to Bode plot for Simulink presentation.
I will not delete my Answer.

请先登录,再进行评论。

回答(1 个)

Star Strider
Star Strider 2021-10-29
Again using the same example from the documentation —
a = [1 0.4 1];
b = [0.2 0.3 1];
w = logspace(-1,1.3);
h = freqs(b,a,w);
fp = 9.68;
hfp = freqs(b,a,[1;1]*fp)
hfp =
0.1923 - 0.0233i 0.1923 - 0.0233i
mag = abs(h);
phase = angle(h);
phasedeg = phase*180/pi;
Gp=0.8881779763;
idx = find(diff(sign(mag-Gp))); % Approximate Indes
wint = interp1(mag([-1:1]+idx),w([-1:1]+idx), Gp) % Interpolated Frequency Value
wint = 1.3077
magint = freqs(b,a,[1;1]*wint) % Interpolated MAgnitude Value
magint =
-0.3369 - 0.8008i -0.3369 - 0.8008i
subplot(2,1,1)
loglog(w,mag)
hold on
plot(fp, abs(hfp(1)),'+r')
plot(wint,abs(magint(1)),'rs')
hold off
grid on
xlabel('Frequency (rad/s)')
ylabel('Magnitude')
yline(Gp,'-g','Gp');
text(wint,abs(magint(1)), sprintf(' \\leftarrow Intersection %.3f rad/s',wint), 'Horiz','left', 'Vert','middle', 'Rotation', -10)
subplot(2,1,2)
semilogx(w,phasedeg)
hold on
plot(fp, rad2deg(angle(hfp(1))),'+r')
plot(wint,rad2deg(angle(magint(1))),'rs')
hold off
grid on
xlabel('Frequency (rad/s)')
ylabel('Phase (degrees)')
text(wint,rad2deg(angle(magint(1))), sprintf(' \\leftarrow Intersection %.3f rad/s',wint), 'Horiz','left', 'Vert','middle', 'Rotation', 10)
Experiment to get different results.
.

类别

Help CenterFile Exchange 中查找有关 Digital Filter Analysis 的更多信息

标签

产品


版本

R2020b

Community Treasure Hunt

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

Start Hunting!

Translated by