Computer Question 1:
Plot and Subplot
You are given the following points, which are given as (x,y) coordinate pairs, with
the y points in scientific notation (4e+010 means 4*10^10):
(20, 1.2e+009)
(25, 1.8e+011)
(30, 2.7e+013)
(35, 4.0e+015
(40, 5.9e+017)
Write Matlab code that displays the following two graphs next to each other
(using the
subplot
function):
a) A standard x-y plot of the points
b) A plot of the points where the y axis is logarithmic
Title the graphs (“X-Y Plot” and “Y Logarithmic”).
Also answer, in one sentence, what you learn about the relationship between x
and y as a result of these plots, and suggest a possible equation for y.
x = 20:5:40;
y = [1.2e+009 1.8e+011 2.7e+013 4.0e+015 5.9e+017];
subplot(1,2,1); plot(x,y); title(
'X-Y Plot'
);
subplot(1,2,2); semilogy(x,y); title(
'Y Logarithmic'
);
You learn that y is exponentially related to x, so you might have y = e
x
,
potentially with constants added in.
-4 if they have minor syntax errors (they had the computer to check answers)
-4 if they are missing titles
-8 if they at least successfully use 2 of the following: subplot, plot, and colon
operator
-10 if they at least successfully use 1 of the following: subplot, plot, and colon
operator
-12 if they seem to kind of understand how to plot things
-14 otherwise
Computer Question 2:
Leap Year
Write Matlab code that does the following: