find x or y at given point for f_cutoff, 0.1*f_cutoff and 10*f_cutoff
3 views (last 30 days)
Show older comments
Olga Rakvag
on 18 Feb 2023
Commented: Star Strider
on 20 Feb 2023
% %Need to replace so it looks the same but with calculation of x at given y= -3.02 in magnitude plot
% and y at -45.01 deg, -84.28 deg, -5,7 deg
% cut-off frequency atbandwidth from datatip -3.02 dB
clc;
clear all; close all; %%matlab
np = tf(0.999, [9.99e-4, 1])
% [mag,phase,w] = bode(np,w);
%plotting av teoretisk vs eksperimentell data
figure (1)
subplot(2,1,1)
bodemag(np,'k-.'); hold on
grid on
% cutoff frekvensen at -3.02 dB found with datatip
yline(-3.02000000267966,'r-','-3.02 dB', 'LabelHorizontalAlignment','left', 'Linewidth', 1.5)
xline(1001.21694896018,'r-','\omega_c = 1001.22 rad/s ','LabelVerticalAlignment','middle', 'Linewidth', 1.5)
title('1. ordens frekvens amplitude respons')
legend ('Simulated 1. order')
subplot(2,1,2)
h = bodeplot(np, 'k-.');
setoptions(h,'MagVisible','off'); hold on, grid on
% %Need to replace so it looks the same but with calculation of x at given y= -3.02 in magnitude plot
% and y at -45.01 deg, -84.28 deg, -5,7 deg
% cut-off frequency atbandwidth from datatip -3.02 dB
%calculate f at mag equal -3.02 dB
xline(1001.21694896018,'r-','\omega_c ','LabelVerticalAlignment','top', 'Linewidth', 1.5)
yline( -45.0100,'r-','-45.01', 'LabelHorizontalAlignment','left','Linewidth', 1.5)
%data avlest fra datatip at 10_w_c [1.001216948960180e+04,-84.276493287076900]
xline(1001.21694896018*10,'b-','10*\omega_c ','LabelVerticalAlignment','t')
yline(-84.276493287076900,'b-','-84.28 deg', 'LabelHorizontalAlignment','left')
% data avlest fra datatip at 0.1_w_c [100.121694895791,-5.72603838444467]
xline(1001.21694896018*0.1,'m-','0.1*\omega_c','LabelVerticalAlignment','b')
yline(-5.72603838444467,'m-','-5.7 deg', 'LabelHorizontalAlignment','left')
% phase_shift[1001.21694882189,-45.0061545314931];
title('')
round(-84.276493287076900, 2)
grid on
0 Comments
Accepted Answer
Star Strider
on 19 Feb 2023
I wrote a short utility program that does exactly that —
% %Need to replace so it looks the same but with calculation of x at given y= -3.02 in magnitude plot
% and y at -45.01 deg, -84.28 deg, -5,7 deg
% cut-off frequency atbandwidth from datatip -3.02 dB
% clc;
% clear all; close all; %%matlab
np = tf(0.999, [9.99e-4, 1])
% [mag,phase,w] = bode(np,w);
%plotting av teoretisk vs eksperimentell data
[mag,phase,wout] = bode(np);
mags = squeeze(mag);
magsdB = mag2db(mags);
phases = squeeze(phase);
ydB = -3.02;
[wi,dBi] = intsx(wout,magsdB,ydB)
ydeg = [-45.01, -84.28, -5,-7];
for k = 1:numel(ydeg)
[wdegi,phdgi] = intsx(wout,phases,ydeg(k));
wdeg(k,:) = wdegi;
phdg(k,:) = phdgi;
end
wdeg
phdg
function [xi,yi] = intsx(x,y,c)
% ARGUMENTS: (x,y): Vectors, c: Constant
zci = find(diff(sign(y-c)));
for k = 1:numel(zci)
idxrng = max(1,zci(k)-1) : min(numel(x),zci(k)+1);
xi(k,:) = interp1(y(idxrng)-c,x(idxrng),0);
yi(k,:) = interp1(x(idxrng), y(idxrng), xi(k));
end
end
I use bode here because it calculates and returns the requisite results.
This finds the appropriate radian frequency values for the chosen dependent variable values. I am sure you can take it from here.
.
6 Comments
More Answers (0)
See Also
Categories
Find more on Plot Customization in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!