Each
of the problems below is intended to be solved by generating a script or
m-file. Be sure to have a very clearly written header for each M-file so that
anyone reading your work can decipher the sort of problems you are solving in
each M-file. Also, be sure to label all axes and assign each plot a title.
Click here
to see what your resulting plots should look like. - Read the HELP
pages on the following functions (either by typing "help" and
then the function name at the MATLAB command prompt, or by clicking
these links): plot
(concentrate on how to plot using different symbols and colors), subplot,
zoom,
figure,
close,
text,
loglog,
semilogx,
semilogy,
prod,
load,
save,
length.
- Start by using
the same M-file you generated for problems #8-14 on
**PS#1**. The objective here will be to modify this M-file using the SUBPLOT command so that now you will make 4 separate plots on a single page. You only have to worry about accomplishing problem #13 from PS#1. Make each of your four plots have a different line style along with separate titles and axis labels. Print the resulting plot figure. - Repeat Problem #2 but now use 4
different data symbols of your choice for each one of the 4 subplots. Be
sure that only the data points are plotted and are not connected by
lines. You should notice that if you plot ALL of the data points using
symbols that graph gets a bit messy. One way to get around this is to
use less points between the minimum (
**W**= ) and maximum (**W**= ). Print the resulting plot figure.
For problems #4 and 5 be sure to use the title, label and text commands to clearly identify what it is you are plotting in each graph.**Submit one plot and one M-file**. Click here to see what your resulting plot should look like. - Generate an
array
**X**that starts at 0.0 and goes to 10.0 in steps of 0.001. - Use the subplot command to
generate 4 plots on a single page which are
(1)**X**vs**e**^{X}, (2)**X**vs**e**^{-X}, (3)**X**vs semilogy(**e**^{X}) and (4)**X**vs semilogy(**e**^{-X}).
For problems #6-9 we are going to write and test an M-file that generates a series expansion of "**e**" which is:
**Submit a single M-file and two plots**. As always, be sure to clearly label each data line in your graph so that I know what you are plotting. Click here to see what your resulting plots should look like. - Generate an
array
**X**that starts at 0.0 and goes to 1.0 in steps of 0.0001. - Plot
**X**vs e^{X}using the built-in Matlab function for "**e**" (i.e., EXP(X)). - Use the series
equivalent for
**e**to calculate 10 new values for**e**and call them**EXP1**,**EXP2**,**EXP3**,**EXP4**...**EXP10**. Here**EXP1**calculates**e**only using the first factorial term (i.e. ),**EXP2**calculates**e**using both the first and second factorial terms (i.e., ),**EXP3**calculates**e**using the first, second and third factorial terms (i.e., ) and so on up to**EXP10**which calculates**e**using the first ten factorial terms. - Now, on the
**same**plot generated in problem #7 plot**X**vs**EXP1**^{X},**X**vs**EXP2**^{X},
**X**vs**EXP3**^{X}and so on up to and including**X**vs**EXP10**^{X}. Use different line styles for each trace and use the TEXT command to tell me what lines correspond to what series expansion (i.e., EXP1, EXP2, ... EXP10). - Now, repeat #8 exactly except
instead of using the plot command use the semilogy command to plot your
data.
For problems #11-13 we are going to examine sinusoidal functions as they grow and decay in an exponential fashion.**Submit a single M-file and a single plot**. Click here to see what your resulting plot should look like.
- Generate an
array
**X**that starts at 0 and goes to 50 in steps of 0.01. - Generate
another array
**Y**that starts at 0 goes to 6.0 where the increments between 0 and 6.0 are such that the length of vector**Y**is the same as vector**X**. - Use the subplot command to
generate 4 plots on a single page evaluating the following functions:
(1)
**Y**vs e^{Y}sin(**X**), (2)**Y**vs e^{-Y}sin(**X**), (3)**Y**vs semilogy(e^{Y}sin(**X**)) and (4)**Y**vs semilogy(e^{-Y}sin(**X**)).**N.B.**remember that you cannot take the logarithm of a negative number ... So you're going to have to do "something'" to your sin function or at least the data it generates to get this problem to come out correctly.
For problems #14-17 we are going to learn how to both save and load ASCII data files.**Submit a single M-file and a single plot**. Click here to see what your resulting plot should look like.
- Write a matlab
M-file to evaluate the following expression: , where Y is
an array that goes from 0 to 5 in steps of .
- Plot
**Y**vs.**X**in one panel of a 4 panel subplot with axis limits as follows : abscissa 0 to 16 and ordinate -30 to +30.**N.B.**For this problem**Y**is the abscissa and**X**is the ordinate. - Now, save
**X**into a data file named PS2.dat using 16-digit ASCII form. Then load this file back into Matlab and plot the data in PS2.dat against the data you generated in problem #14. That is plot**X**vs. PS2.dat in one of the panels of a 4 panel subplot. - Multiply the
two data vectors together (
**X**·PS2) and plot**X**vs.**X**·PS2 in one of the panels of a 4 panel subplot. For this plot set the axis limits as follows: abscissa -30 to +30 and ordinate 0 to 750. - Subtract the
two data sets (
**X**- PS2) and plot**X**vs. (**X**- PS2) in the last remaining panel of the 4 panel subplot.
To continue on to the next
core lesson, click here. |