MATLAB Lesson 2
%
clc, clearvars
x=linspace(-10,10);
Example y1= (-(x-3).^2) + 10;
y2= (-(x-3).^2) + 15;
a) -10 to 10 y3= (-(x-5).^2) + 10;
figure(1)
plot(x,y1,'*') % using * to display the data points
xlabel('x') % add the name of x label
b)
ylabel('y') % add the name of y label
c) - title('y vs. x ~ Problem A') % add the title
grid on % add the grid in the graph
Answer
-10,10);
y1 - -3).^2) + 10;
- -
- -
% Add the following to create two plots in the same graph by hold on function
hold on
plot(x,y2,'bv') % use blue triangle to display the y2
legend('Y1', 'Y2') % add the legend of your data set
More examples for Matlab Plot
-
Line Plot with Confidence Bounds
l
the t object. e to
.
x = 0:0.2:10;
xlim([0,2]) % change the range of x axis to [0,2] y = besselj(0, x);
xconf = [x x(end:-1:1)] ;
yconf = [y+0.15 y(end:-1:1)-0.15];
figure
p = fill(xconf,yconf,'red');
[Link] = [1 0.8 0.8];
[Link] = 'none';
hold on
plot(x,y,'ro')
hold off
Plot Dates and Times
as
x-, y- z-
the
adsheet or comma-separated value (CSV) file, you can include the date
and time data in your plots.
Plot Date and Time Data
x- y-
The x-
x-
XDates = [datetime(2021,6,1:30) datetime(2021,7,1:31)];
YNumsForXDates = sin(0:0.1:6);
plot(XDates,YNumsForXDates)