I need Matlab help comparing bode plots neatly

In summary, the conversation discusses a problem with overlaying theoretical and actual data plots in MATLAB. The person is trying to compare gain and phase difference data, and has successfully plotted each separately but cannot overlay them onto the bode plot. They share their code and mention that adding a "hold on" command did not work. However, they later figure out that the order of the plots listed in the code matters in achieving the desired overlay.
  • #1
Vagabond7
50
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
  • #2
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.
 

1. How do I compare bode plots in Matlab?

To compare bode plots in Matlab, you can use the "bodeplot" function. This function takes in multiple transfer functions as inputs and plots them on the same graph for easy comparison.

2. Can I customize the appearance of the bode plots in Matlab?

Yes, you can customize the appearance of bode plots in Matlab. You can change the color, line style, and markers of the plot using the "bode" command and its various options.

3. Is there a way to save the bode plots in Matlab for future use?

Yes, you can save the bode plots in Matlab by using the "saveas" function. This will save the plot as an image file that can be easily accessed and used in the future.

4. How can I plot multiple bode plots in separate figures?

To plot multiple bode plots in separate figures in Matlab, you can use the "subplot" function. This function allows you to create multiple subplots within a single figure, each representing a different bode plot.

5. Is there a way to compare bode plots from different datasets in Matlab?

Yes, you can compare bode plots from different datasets in Matlab by using the "hold on" command. This allows you to plot multiple datasets on the same graph for easy comparison.

Similar threads

  • MATLAB, Maple, Mathematica, LaTeX
Replies
1
Views
4K
  • Engineering and Comp Sci Homework Help
Replies
4
Views
4K
  • Engineering and Comp Sci Homework Help
Replies
4
Views
2K
  • Engineering and Comp Sci Homework Help
Replies
14
Views
7K
  • Engineering and Comp Sci Homework Help
Replies
1
Views
2K
Back
Top