Plot measured Filter data

5 views (last 30 days)
Sebastian D.
Sebastian D. on 20 May 2022
Edited: Sebastian D. on 20 May 2022
Hi all,
I got mearsurement data from a real band pass filter. To make a professional plot, I am using matlab. The x-axis is in logarithmic scale. While plotting the magnitude it is working perfectly. Unfortunately, it does not work for the phase. But when I plot it with libre office calc, I get the correct result. The excel file is attached. It would be great if you could give a hint. Thank you in advance!
Plot with libre office calc:
The code is as follows:
T = readtable('Plot.xls');
gain = T{(22:109),1};
frequency = T{(22:109),2};
phase = T{(22:109),3};
%plot gain
subplot(2,1,1);
semilogx(gain, frequency); %x axis has log scale
title('Bode Diagram')
xlabel('Frequency [Hz]')
ylabel('Magnitude [dB]')
%plot phase
subplot(2,1,2);
semilogx(phase, frequency); %x axis has log scale
xlabel('Frequency [Hz]')
ylabel('Phase [deg]')
grid on

Accepted Answer

VBBV
VBBV on 20 May 2022
Edited: VBBV on 20 May 2022
T = readtable('Plot.xls')
T = 121×3 table
F A P _______ _______ ______ 0.1 -19.679 44.63 0.11221 -30.408 -160.9 0.1259 -26.056 98.76 0.14127 -24.935 87.441 0.15851 -25.049 84.581 0.17786 -24.997 95.553 0.19957 -24.801 66.816 0.22393 -22.482 92.478 0.25127 -21.834 95.452 0.28194 -20.728 80.841 0.31635 -19.421 94.68 0.35497 -18.53 92.847 0.39829 -17.533 92.878 0.44691 -16.923 88.998 0.50146 -15.615 90 0.56267 -14.874 90.817
frequency = T{(22:109),1}; % change this to ffequency
gain = T{(22:109),2};
phase = T{(22:109),3};
%plot gain
subplot(2,1,1);
semilogx(frequency,gain); %x frequency as x-scale
grid
title('Bode Diagram')
xlabel('Frequency [Hz]')
ylabel('Magnitude [dB]')
%plot phase
subplot(2,1,2);
semilogx(frequency,phase); %x here too
xlabel('Frequency [Hz]')
ylabel('Phase [deg]')
grid on
  2 Comments
Sebastian D.
Sebastian D. on 20 May 2022
Thank you very much for your help!

Sign in to comment.

More Answers (0)

Products


Release

R2018b

Community Treasure Hunt

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

Start Hunting!

Translated by