MATLAB Plotting y=x Function in Matlab: Tips for Beginners

Click For Summary
To plot a function in MATLAB without defining specific values for x, users can create a range of x values using the colon operator or the linspace function. For example, using "x = -10:0.1:10;" or "x = linspace(-10, 10, 100);" allows for the generation of x values over a specified interval. After defining x, the function can be plotted using the plot command, such as "y = x.^2;" followed by "plot(x, y);". This approach mirrors the functionality of TI-83/84 calculators, enabling users to graph functions effectively in MATLAB.
djdato
Messages
5
Reaction score
0
I am new to Matlab and i need to plot a function. However, using y=x as an example it always comes up saying that x is not defined. How do i plot the function without specifying a specific value for x? Graphing y=x is not my real problem. I am used to using TI-83/4 graphics calculators and typing a function like y=x^2 and just graphing it. But i can't do it on MATLAB as it always needs me to define x.

Regards,
djdato
 
Last edited:
Physics news on Phys.org
My advice is: RTM
 

Similar threads

  • · Replies 5 ·
Replies
5
Views
2K
  • · Replies 4 ·
Replies
4
Views
2K
  • · Replies 11 ·
Replies
11
Views
3K
  • · Replies 1 ·
Replies
1
Views
5K
  • · Replies 5 ·
Replies
5
Views
2K
  • · Replies 3 ·
Replies
3
Views
2K
  • · Replies 2 ·
Replies
2
Views
4K
  • · Replies 11 ·
Replies
11
Views
4K
  • · Replies 1 ·
Replies
1
Views
4K
  • · Replies 6 ·
Replies
6
Views
2K