How to plot Specific data points on individual bode plots.

49 vues (au cours des 30 derniers jours)
Arminas Bartkus
Arminas Bartkus le 5 Jan 2021
Commenté : Adam Danz le 6 Jan 2021
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.

Réponse acceptée

Adam Danz
Adam Danz le 6 Jan 2021
Modifié(e) : Adam Danz le 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')
  2 commentaires
Arminas Bartkus
Arminas Bartkus le 6 Jan 2021
appreciate it
Adam Danz
Adam Danz le 6 Jan 2021
Thanks for providing a concise working example!

Connectez-vous pour commenter.

Plus de réponses (0)

Catégories

En savoir plus sur Plot Customization dans Help Center et File Exchange

Produits


Version

R2019b

Community Treasure Hunt

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

Start Hunting!

Translated by