MATLAB I need Matlab help comparing bode plots neatly

Click For Summary
The discussion focuses on overlaying theoretical and actual Bode plots in MATLAB for a presentation. The user has successfully created separate plots for gain and phase differences but struggled to overlay them on the Bode plot. They initially faced issues with the "hold on" command not working as intended. Ultimately, they discovered that the order of commands in the code was crucial for achieving the desired overlay. The solution involved placing the "hold on" command strategically between the gain and phase plots and the Bode plot.
Vagabond7
Messages
50
Reaction score
11
This definitely isn't a homework question as the work is already done, I'm just trying to make my presentation neater for some reports I'm turning in.

I am comparing theoretical data collected from a filter, to the actual data collected. I want to overlay the two to make the comparison. I am trying to do this for both the gain, and the phase difference. I have a plot for the gain, I have a plot for the phase difference, and I have the bodeplot that has both. But I can't seem to overlay everything.


Here is the code I have if any MATLAB whizzes can help me figure out how to do it. All of the plots themselves are correct, I don't need help with them. I just want to overlay the gain plot and phase plot over the respective parts of the bode plot.

sys=tf([0 -8200], [0 .12874 1570])
bodeplot(sys) %this is the bodeplot for the theoretical values

x=[100 1885 3142 10681 12566 14451 31416 628318 1000000]; %start of the gain plot for data
V=[10.2 10.2 9.8 7.6 7 6.4 3.8 .3 0];
y=20*log10(V./2);
subplot(2,1,1); semilogx(x,y,'r') %this is the end of gain plot for data

P=[189 189 165 140 136 126 116 92 92];
subplot(2,1,2); semilogx(x,P,'r') %This is the phase plot for real data

% subplot plots both the gain and phase plots together


simply adding a "hold on" command in there doesn't over lay the bode plot on the other plots. Any suggestions or commands anybody can think of the get everything lined up?
 
Physics news on Phys.org
I figured it out. The "hold on" command works in the order that the plots are listed so essentially the form of the code that worked was

gain plot
hold on
bode plot
hold on
phase plot

and then it overlapped everything the way I wanted it. Just in case anybody else wants to know.
 

Similar threads

  • · Replies 4 ·
Replies
4
Views
5K
  • · Replies 3 ·
Replies
3
Views
4K
  • · Replies 14 ·
Replies
14
Views
9K