Computer Question 1:
Plot and Subplot
Begin by setting x = 0:10:100, and y = [ 2 , 44053 , 9.7033e+008, 2.1373e+013,
4.7077e+017, 1.0369e+022, 2.2840e+026, 5.0309e+030, 1.1081e+035,
2.4408e+039, 5.3762e+043 ]
(Note that you don’t
have to recopy this portion of code to your blue book.)
Now, write Matlab code
that creates a subplot with the following four graphs,
displayed next to each other:
1) standard x-y plot
2) a plot where the x axis uses a logarithmic scale
3) a plot where the y axis uses a logarithmic scale
4) a plot where both axes use logarithmic scales
From these graphs, also deduce the relationship
between x and y. Note that you
can enter these large numbers by simply typing 5.3762e+043 or similar.
x = 0:10:100;
y = [2 44053 9.7033e+008, 2.1373e+013, 4.7077e+017, 1.0369e+022,
2.2840e+026, 5.0309e+030, 1.1081e+035, 2.4408e+039, 5.3762e+043];
subplot(2,2,1); plot(x,y);
subplot(2,2,2); semilogx(x,y);
subplot(2,2,3); semilogy(x,y);
subplot(2,2,4); loglog(x,y);
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)