TASK: Plot several formulas on the same graph.
COMMENT: The first five Chebyshev polynomials of the second kind have the formulas
u0(x) = 1
u1(x) = 2x
u2(x) = 4x^2 - 1
u3(x) = 8x^3 - 4x
u4(x) = 16x^4 - 12x^2 + 1
We want to make one plot that displays all five polynomials, over the range [-1,+1].
INSTRUCTIONS:
Create an xlist of N linearly spaced x values between -1 and +1.
A value of N around 100 might be reasonable.
We are going to create 5 separate lists of y values, and so we
might want to name them u0, u1, u2, u3 and u4.
Actually, u0 is a special case. We need a list that has the value 1
repeated N times (N is the number of x values)
u0 = ones ( 1, n );
The next formula is easy:
u1 = 2 * xlist;
Now you have to set the values of u2, u3, and u4. Since xlist is a
list, remember the rules for doing arithmetic on lists!
u2 =
u3 =
u4 =
In order to plot all five functions, together, we have two choices:
A) use ONE plot command:
plot ( xlist, u0, xlist, u1, xlist, u2, ... )
B) use hold on, 5 plot commands, and hold off
hold on
plot ( xlist, u0 )
plot ( xlixt, u1 )
???
hold off
Follow your plot statement by commands that
1) turn on grid lines;
2) label the X axis;
3) label the Y axis.
4) title the plot.
Your last command should save a copy of your plot:
print ( '-djpeg', 'hw034.jpg' );
CHECK:
SUBMIT: I only need your script file "hw034.m". I do NOT need your plot file. Your script file should begin with:
% hw034.m
% YOUR NAME
% This script (describe what it does)