How to plot Specific data points on individual bode plots.

189 views (last 30 days)
Hi, so I am analysing a DC motor speed using a PI controller.
Anyway I have collected data for the amplitude ratio of the achieved amplitude against the command amplitude aswell as the time period, time difference between peaks and thus the phase angle in degrees. Here is me defining the data in MATLAB.
Fq = [5 10 50 100 500 1000]; %Command Frequencies
Ar = [0.75472144 0.54075 0.11894 0.054723 0.005801 0.00157]; %Amplitude ratio (Achieved/Command)
Ph_deg = [-2.036864964 -5.388668069 -56.78613362 -68.88060233 -120.9170132 -144.9197795]; %Phase angle (Deg)
Ph_rad = Ph_deg*(pi/180); %Phase angle (Rad)
I have then estimated the transfer function for this system and have plotted a bode plot using:
zfr = Ar.*exp(sqrt(-1)*Ph_rad);
data = frd(zfr, Fq);
nz = 1;
np = 2;
Gc = tfest(data,np,nz);
bode(Gc)
Obviously I have my experimental data from my simulations I.e. the frequencies for x axis and the magnitude in dB that I can calculate from the ratio and the phase angle in degrees I have.
How can I choose which graph (Magnitude or Phase angle) and how can I plot these specific experimental data points onto the bode plots?
I have tried many different solutions but none have come to achieve what I require.

Accepted Answer

Adam Danz
Adam Danz on 6 Jan 2021
Edited: Adam Danz on 6 Jan 2021
Fq = [5 10 50 100 500 1000]; %Command Frequencies
Ar = [0.75472144 0.54075 0.11894 0.054723 0.005801 0.00157]; %Amplitude ratio (Achieved/Command)
Ph_deg = [-2.036864964 -5.388668069 -56.78613362 -68.88060233 -120.9170132 -144.9197795]; %Phase angle (Deg)
Ph_rad = Ph_deg*(pi/180); %Phase angle (Rad)
zfr = Ar.*exp(sqrt(-1)*Ph_rad);
data = frd(zfr, Fq);
nz = 1;
np = 2;
Gc = tfest(data,np,nz);
bode(Gc)
% Get axis handles
% axh(3) is the upper plot
% axh(2) is the lower plot
% axh(1) is used for labels
axh = findall(gcf, 'type', 'axes');
% Add objects to upper axis
hold(axh(3),'on')
plot(axh(3),Fq, 20*log10(Ar), 'r--','LineWidth',1)
% Add objects to lower axis
hold(axh(2),'on')
plot(axh(2),Fq, Ph_deg, 'r--','LineWidth',1)
Notice that the added lines extend beyond the axis limits. To adjust the axis limits,
set(axh(2:3),'YLimMode','Auto')

More Answers (0)

Products


Release

R2019b

Community Treasure Hunt

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

Start Hunting!