[X1,X2] = meshgrid(-8:.2:8,-10:.2:10); contour(X1,X2, sin(X1-X2) + X1.^3./20 ,[0 0],'b-'); hold on contour(X1,X2, cos(X1+X2) - X2.^2./20 ,[0 0],'r--'); hold off
Note that you MUST use .* ./ .^ instead of * / ^ for element-wise arithmetic operations with the arrays X1 and X2.
Problem 1:
1(b): You can get equidistant nodes using
x=linspace(-pi,pi,10) .
For
1(c): Use the bound for the Chebyshev polynomial
below.
Problem 2: Use [x,y] = pickpoints(9) to
enter the points. Download pickpoints.m
For (a) do the following:
t=1:9; te=1:.05:9;t, x use
spline to evaluate the interpolating function at points
te, yielding vector xet, y use
spline to evaluate the interpolating function at points
te, yielding vector yeplot(x,y,'o',xe,ye); axis equalFor (b) use polint instead of spline.
Problem 3: Remember to take the logarithms
(log in Matlab) of the population values before doing the least
squares fit: p=[75.995,...,249633]; q=log(p) .
Print out the vector c which you get for (i),(ii),(iii) and
check that they are the same (up to roundoff errors). Then use one of
those c vectors for the plot and for the predicted
population.
Problem 4: Download co2.dat , then use in Matlab load
co2.dat (not load co2 as stated in the
problem).
IMPORTANT:
Use x = 1:length(co2) since
x is the time in months (the seasonal variations in
(ii) have a period of 12 months.)