how to plot on the same bode plot a manual function plot() with function bode()?

11 vues (au cours des 30 derniers jours)
I have a a transfer function that I plotted manually using Plot(w,abs(f1(w))) and I have another function that I used directly bode(f2(s)). I would like to plot them both in one bode plot?
the
bode()
hold on
plot()
gives errors

Réponse acceptée

Star Strider
Star Strider le 18 Mai 2020
I am not certain that what you want to do is possible with the bode function. The best option is to use the example in Obtain Magnitude and Phase Data and then plot those results together with the data you already have.
  4 commentaires
SimTec
SimTec le 18 Mai 2020
Thank you i just did that and I found out there is a slight difference,here the code
close all
w_5 = linspace(10e-3,1e3,10240);
[mag_5,phase_5]=bode(sys_five,w_5);
mag_5_1=mag_5(:,[1:10240]);
%wout_5=w_5(1:71,:);
plot(w_5, 20*log10(mag_5_1))
hold on
opts= bodeoptions;
opts= bodeoptions('cstprefs');
opts.PhaseVisible = 'off';
bode(sys_five,opts);
legend({' exctracted','normal bode plot'});
this the magnitude I get
Star Strider
Star Strider le 18 Mai 2020
I am not certain what you are doing, or whether you are starting with the FIR filter or the control system, then synthesising the other from it. (Those are not exact copies of each other, however I cannot determine if they are sufficiently similar to be acceptable to you.)
If you are going from the filter to the control system, and have the System Identification Toolbox, one option is to use the filter impulse resonse (either time-domain or frequency domain), and then estimate a system that will approximate it.
If you are going the other direction (control system to filter), you will need the Signal Processing Toolbox to create a FIR filter using the least-squares or Parks-McClellan procedure to approximate the frequency-domain transfer function of it.

Connectez-vous pour commenter.

Plus de réponses (1)

Rajiv Singh
Rajiv Singh le 10 Juin 2020
You could try:
G = frd(f1(w),w); % assuming f1(w) is a complex numeric vector
bode(G,f2)

Community Treasure Hunt

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

Start Hunting!

Translated by