\"
(for linear systems and least squares), lu,
fzero, ode45, quad
TA Stacey Nicholls,
son@math.umd.eduproblem_a.m,
problem_b.m etc. for each part of the
problem, so that running e.g. problem_a generates all
results, graphs, animations for part (a), properly labeled, without
any user input.dpanim.m for animating resultsx1'' =where v = [(x1'-v·(x1'-w)
x2'' =-1-v·x2'
- w)2 +
(x2')2]1/2. -0.1 in (d) (not
-0.3).coastertrack.mplot3 and
comet3, plotting graph of function
f(x,y) using surfnice3d.mppval, ppval1,
ppval2fzero fminbndode45ode45 at an
"Event"global: pendulum examplecomet and
comet3: You need output with
uniformly spaced t-values by using e.g.
[t,y]=ode45('f',0:.01:10,y0): pendulum examplewww.wam.umd.edu/~petersd/460Use this if there is a problem with the normal address www.glue.umd.edu/~tvp/460
office hours of instructor and grader, grading policy
num2bin.m
and bin2num.m (note that you
have to put the files where
Matlab can find them) x = A\b or[L1,U] = lu(A); % compute
factorization A=L1 U using Gaussian elimination with pivoting,
choosing pivot candidates with largest absolute valuey = L1\b; % "forward substitution"
x = U\y; % back susbstitution
condition = condestdec(L1,U) %
estimate condition number of A (for 1-norm)norm(x,1) ,
norm(x,2) , norm(x,inf) cond(A,1),
cond(A,2), cond(A,3) (in all cases
inv(A) is computed)condest(A)
(actually computes LU decomposition of A) condestdec(L1,U) condestdec.m ,
for Matlab 5 use condestdec5.m
instead)xj = (a+b)/2 + cos(Then(j-1/2)/n) (b-a)/2 for j = 1,...,n.
|(x-x1)...(x-xn)|2 ((b-a)/4)n for x in [a,b]
x contains the x-coordinates of the nodes, the column
vector y contains the function values at the nodes, the
vector yp contains the derivatives at the nodes. The vector
xi contains the points where we want to evaluate the
interpolating function, the vector yi contains the
corresponding values of the interpolating function.
hermite.m . Then use yi =
hermite(x,y,yp,xi)yi = spline(x,[sl;y;sr],xi) yi =
spline(x,y,xi)Using ppval, ppval1,
ppval2 for evaluating
splines: First download ppval1.m, ppval2.m :
x = linspace(0,2*pi,5); y = sin(x); % use 5 points
pp = spline(x,y) % find coefficients pp of not-a-knot
spline p(x)
xe = linspace(0,2*pi,9); % evaluate at 9 points xe
ye = ppval(pp,xe) % values of spline p(x)
ye1 = ppval1(pp,xe) % values of p'(x)
ye2 = ppval2(pp,xe) % values of
p''(x)
[Q0,R0] = qr(A,0)
b0 = Q0'*y
c = R0\b0c = A\yxs = fzero('f',[a,b]) for function in m-file
f.mf=inline('sin(x)','x'); xs=fzero(f,[3,4])xs = fminbnd('f',a,b) for
function in m-file f.mf=inline('sin(x)','x'); xs=fminbnd(f,1,7) ode45: Default
for RelTol is 1e-3, default for AbsTol is 1e-6
opts = odeset('RelTol',1e-4,'AbsTol',1e-7);
[t,y] = ode45('f',[t0,T],y0,opts);
ode*, error tolerance, event
locationode45: try this first (uses methods of order 4,5)ode23: sometimes better for lower accuracy (uses methods of
order 2,3)ode113: sometimes better for higher accuracy (uses variable
order) ode15s: for "stiff" problems, high accuracy (uses variable
order)ode23s: for "stiff" problems, low accuracy (uses order
2)ode45(@f,...) even if f is in a separate
file f.m), version for
Matlab 5 using fev.m You will only receive credit for your homework if you follow the following rules:
For each problem you must hand in
;'' at the end of lines to suppress the output of
uninteresting intermediate results (especially if these are large
arrays).disp or fprintf commands to for text output,
see examples. Use the
title, xlabel, ylabel,
legend commands to label your graphs, see example.print -dps figXY.ps in Matlab produces a postscript file
figXY.ps of the current figure which you can then send to the
printer.) tap
matlab and then matlab & . This
starts the integrated enviroment (with editor and debugger). matlab
-nojvm . In this way you can also use Matlab remotely (but
you won't see any graphs unless you have an X-server running on your
local machine). You can use your favorite editor (nedit,
pico,
vi, emacs) for
writing m-files.