I am trying to calculate the peak value of the bodemag plot. Attached is the code I am trying to use
[gpeak,fpeak] = getPeakGain(SS_1)
gpeak_dB = 20*log10(gpeak);
However that doesn't seem to work for bodemag plots, only for bode plots because it isn't giving me the correct peak for the plot attached.
How do I calculate the peak of a bodemag plot?

 채택된 답변

Star Strider
Star Strider 2020년 3월 1일

0 개 추천

Try this:
F = openfig('untitled.fig');
getF = get(F);
Lines = findobj(F, 'Type','Line');
for k = 1:numel(Lines)
X{k} = Lines(k).XData;
Y{k} = Lines(k).YData;
[Ymax,Idx] = max(Y{k});
FM{k,:} = [X{k}(Idx) Ymax Idx];
end
MagFreq = array2table(cell2mat(FM), 'VariableNames',{'Frequency','Magnitude','Index'})
producing:
MagFreq =
Frequency Magnitude Index
_________ ___________ _____
NaN NaN 1
NaN NaN 1
1e-20 1.2722e-14 1
1e-20 0 1
1e-20 1.2722e-14 1
1e-20 2.5444e-14 1
1e-20 0 1
1e-20 1.7358e-14 1
1.6051 0.52101 35
1e-20 -2.5073e-14 1
1.3159 0.062431 32
1e-20 -2.5073e-14 1
It is not difficult to extract the values, however it is definitely not straightforward.

댓글 수: 4

JD
JD 2020년 3월 1일
Hi Star Strider,
Thanks for the quick response.
If I am looking at the table correctly, i would pick the largest magnitude in the table as the maximum value of the bodemag plot, is that correct?
Thanks
Star Strider
Star Strider 2020년 3월 1일
My pleasure.
If I am looking at the table correctly, i would pick the largest magnitude in the table as the maximum value of the bodemag plot, is that correct?
It depends on the information you want. There are 12 entries, 10 of them finite. I have no idea what they represent because I only have the figure that plots them.
So, probably yes. The maximum magnitude is 0.52101 dB at 1.6051 rad/s
Note that the values are in dB because they are plotted in dB. No conversion to dB is necessary.
JD
JD 2020년 3월 1일
That makes a lot of sense! Thank you so much for your input and help!
Star Strider
Star Strider 2020년 3월 1일
As always, my pleasure!

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

도움말 센터File Exchange에서 Time and Frequency Domain Analysis에 대해 자세히 알아보기

질문:

JD
2020년 3월 1일

댓글:

2020년 3월 1일

Community Treasure Hunt

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

Start Hunting!

Translated by