Professional Documents
Culture Documents
Y 5 X +2 X Y: Values Ranging From
Y 5 X +2 X Y: Values Ranging From
Y 5 X +2 X Y: Values Ranging From
In this class we are going to look at 2D plots, mainly linear and Quadratic graphs.
To plot the function y=5 x +2on the interval [−1; 1] we first create a vector of x values ranging from
−1 to 1, then compute the y values, and finally plot the result:
MATLAB enables you to add axis labels and titles. For example, using the graph from the previous
example, add an x and y -axis labels.
Now label the axes and add a title as shown below:
xlabel('x')
ylabel('y')
title('Plot of y=5x+2')
2
y
-1
-2
-3
-1 -0.8 -0.6 -0.4 -0.2 0 0.2 0.4 0.6 0.8 1
x
Exercise: Use MATLAB to plot y=x 2 +5 x+ 4 on the interval [−10:5 ] and add axis labels and titles.