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

Click For Summary

Discussion Overview

The discussion revolves around plotting figures in MATLAB, specifically addressing issues encountered by a new user trying to replicate a plot from a file. The scope includes technical explanations and troubleshooting related to MATLAB code for plotting mathematical functions.

Discussion Character

  • Technical explanation, Homework-related

Main Points Raised

  • A participant shares their MATLAB code and expresses difficulty in achieving the desired plot.
  • Another participant provides links to external tutorials on MATLAB plotting.
  • Some participants point out that the variable beta_square is not in decibels (dB) and that the angle theta is not in degrees, suggesting conversions are necessary.
  • There is a correction regarding the use of division in the calculation of theta, with emphasis on using element-wise division (./) instead of regular division (/) due to w being a vector.
  • A later reply acknowledges the correction about the division operator and expresses gratitude for the help.

Areas of Agreement / Disagreement

Participants generally agree on the need for corrections in the code, particularly regarding the conversion of units and the proper use of division operators. However, there is no consensus on the overall approach to plotting, as the original poster's specific issue remains unresolved.

Contextual Notes

Limitations include potential misunderstandings about the requirements for plotting in dB and degrees, as well as the specific context of the original plot that the user is trying to replicate.

Who May Find This Useful

Individuals learning MATLAB, particularly those interested in plotting functions and troubleshooting related coding issues.

Nate Duong
Messages
125
Reaction score
4
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

Last edited by a moderator:
Physics news on Phys.org
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 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.
 

Similar threads

  • · Replies 5 ·
Replies
5
Views
3K
  • · Replies 1 ·
Replies
1
Views
2K
  • · Replies 1 ·
Replies
1
Views
3K
  • · Replies 10 ·
Replies
10
Views
3K
Replies
2
Views
3K
  • · Replies 1 ·
Replies
1
Views
3K
  • · Replies 5 ·
Replies
5
Views
4K
  • · Replies 6 ·
Replies
6
Views
4K
  • · Replies 9 ·
Replies
9
Views
5K
  • · Replies 1 ·
Replies
1
Views
2K