Why Are My Bode Plot Results in MATLAB Different from LTSPICE?

In summary, the conversation discussed the process of creating a Bode Plot for a lab project in an Electronics Course. The student needs to use MATLAB to obtain theoretical magnitudes at specific frequencies for both a high and low pass filter. They have a good understanding of the transfer functions, but are encountering discrepancies in the values obtained from their code. They are advised to check their values for RC, review their code for any errors, and compare their results with those from LTSPICE.
  • #1
samdunhamss
10
0

Homework Statement


I'm working on a Lab for my Electronics Course and need to use MATLAB to create a Bode Plot to get the data for my theoretical Magnitudes at frequencies between 50Hz and 500 Hz. The Resistor has a value of 1k and the Capacitor has a value of 1uF.
I need one for both a high and low pass filter.


Homework Equations


I believe the transfer functions are
H= 1/(s*RC + 1) for the lowpass
and
H= s*RC/(RC*s+1)



The Attempt at a Solution


The MATLAB code I use
s=tf('s');
RC = .000001*1000;
H=1/(RC*s+1);
h=s*RC/(1+RC*s);
W=[50:50:500];
[MAG,PHASE] = bode(H,W);
[MAG,PHASE] = bode(h,W);
Now these are done in real time, not in a .m file.
The problem is that the values are nothing what I expected. When I mess around with the circuit in Transient Analysis in LTSPICE I get values close to what I need, but not in a convenient list form like I would prefer. I think my problems in MATLAB arise somewhere in my transfer functions.
If it's of any consequence the input signal is a simple sine wave with an amplitude of 1V.
 
Physics news on Phys.org
  • #2


Hello, thank you for sharing your progress on your lab project. It seems like you have a good understanding of the transfer functions for both the high and low pass filters. However, I would recommend double checking your values for RC and making sure they are in the correct units. It's also possible that there may be some small errors in your MATLAB code that are affecting the results. I suggest trying out different values for RC and also checking your code for any mistakes. Additionally, it may be helpful to plot the theoretical magnitude values alongside the values obtained from LTSPICE to see where the discrepancies lie. Good luck with your project!
 

FAQ: Why Are My Bode Plot Results in MATLAB Different from LTSPICE?

What is a Bode plot in Matlab?

A Bode plot in Matlab is a graphical representation of a system's frequency response. It shows the magnitude and phase of the system's transfer function as a function of frequency. This plot is commonly used to analyze control systems and filter designs.

How do I create a Bode plot in Matlab?

To create a Bode plot in Matlab, you can use the bode function. This function takes in the transfer function of the system as an input and outputs a plot with the magnitude and phase response. You can also customize the plot by changing the frequency range and adding labels and legends.

Why am I getting a "Bode plot trouble" error in Matlab?

The most common reason for getting a "Bode plot trouble" error in Matlab is due to an incorrect transfer function or frequency range input. Make sure that the transfer function is in the correct format and that the frequency range is appropriate for the system. Additionally, check for any other syntax errors in your code.

How can I troubleshoot problems with my Bode plot in Matlab?

To troubleshoot problems with your Bode plot in Matlab, you can check the transfer function and frequency range inputs, as well as the syntax of your code. You can also try plotting the Bode plot for a simpler system to see if the error persists. Additionally, you can refer to Matlab's documentation or seek help from online forums or communities.

Can I export a Bode plot from Matlab?

Yes, you can export a Bode plot from Matlab as an image or a vector graphics file. To do this, you can use the saveas function and specify the desired file format. You can also copy and paste the plot into other programs, such as Microsoft Word or PowerPoint, for further use.

Similar threads

Replies
4
Views
3K
Replies
8
Views
3K
Replies
4
Views
3K
Replies
4
Views
4K
Replies
13
Views
4K
Replies
4
Views
7K
Back
Top