Learn How to Plot Figures in MATLAB: Step-by-Step Guide and Helpful Tips

In summary, the conversation is about a person who is new to using MATLAB and is having trouble plotting a figure based on a specific file. They share their code and ask for help from the group. Someone suggests using tutorials from the mathworks website and points out some errors in the code that need to be corrected for the plot to be accurate.
  • #1
Nate Duong
126
3
Dear group,

I am new with MATLAB and trying to plot these figure out as the file request.

I tried but could not get the same plot as the file has.

I hope anyone can help. Here is the code which i am working on.

Thank you.
Matlab:
fc = 553e6;
w   = 0:2*pi*fc*1e-2:100*2*pi*fc;
pau = 0.33;
tau = 0.2e-9; % in nano second

% beta_square = zeros(1,length(w));

beta_square = 1 + 2*pau*cos(w*tau) + pau^2;
theta  = atan(-pau*sin(w*tau)/(1+pau*cos(w*tau)));

figure,plot(w,beta_square)
figure,plot(w,theta)
 

Attachments

  • plot matlab.pdf
    198 KB · Views: 335
Last edited by a moderator:
Physics news on Phys.org
  • #3
your beta_square is not in dB and the angle is not in degrees you will have to convert.

also
Code:
 theta  = atan(-pau*sin(w*tau)./(1+pau*cos(w*tau)));
you need a ./ not just / for the division because w is a vector not a scalar.
 
  • #4
Dr Transport said:
your beta_square is not in dB and the angle is not in degrees you will have to convert.

also
Code:
 theta  = atan(-pau*sin(w*tau)./(1+pau*cos(w*tau)));
you need a ./ not just / for the division because w is a vector not a scalar.
@Dr Transport: oh yeah, I missed that dot, that's why I received only scalar not a vector.
Thank you, for the help.
 

Related to Learn How to Plot Figures in MATLAB: Step-by-Step Guide and Helpful Tips

1. What is MATLAB and why is it useful for plotting figures?

MATLAB is a programming language and computing environment commonly used by scientists and engineers for data analysis, visualization, and other mathematical tasks. It is particularly useful for plotting figures because it has built-in functions and tools that make it easy to create high-quality graphs and charts.

2. How can I import data into MATLAB for plotting?

You can import data into MATLAB by using the importdata function, which allows you to load data from a variety of file formats such as CSV, Excel, and text files. You can also copy and paste data directly into the MATLAB workspace or create arrays manually.

3. What are some tips for customizing figures in MATLAB?

To customize your figures in MATLAB, you can use a variety of built-in functions and tools. Some helpful tips include using the figure function to create multiple plots in one figure, using the plot function to change the appearance of your graph (e.g. line color, style, and thickness), and using the title, xlabel, and ylabel functions to add labels to your axes.

4. How can I save my figures in MATLAB for use in other documents?

To save your figures in MATLAB, you can use the saveas function. This allows you to save your figures in a variety of formats such as PNG, JPEG, and PDF. You can also use the exportgraphics function to save your figures in vector graphics formats such as EPS and SVG, which are useful for publications.

5. Can I add annotations or text to my figures in MATLAB?

Yes, you can add annotations and text to your figures in MATLAB using the text function. This allows you to add labels, titles, and other text to specific locations on your graph. You can also use the annotation function to add arrows, shapes, and other graphical elements to your figures.

Similar threads

  • MATLAB, Maple, Mathematica, LaTeX
Replies
1
Views
2K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
1
Views
1K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
1
Views
2K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
10
Views
2K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
2
Views
1K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
1
Views
1K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
5
Views
1K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
1
Views
764
  • MATLAB, Maple, Mathematica, LaTeX
Replies
4
Views
2K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
6
Views
3K
Back
Top