Sample Exercises for Matlab
- Write a subroutine to calculate the binomial factor:

- Write a subroutine which returns the first n
Fibonacci numbers Fi, i=1,..,n,
where F1=F2=1,
and
Fi+1=Fi+Fi-1
- Write a subroutine which prints out the first n
rows of Pascal's triangle. An element in a row is defined
by the addition of neighbouring elements in the previous
row: 1
1 1
1 2 1
1 3 3 1
1 4 6 4 1
- Write a subroutine which returns the value of the
Laguerre Polynomial. The Laguerre Polynomial requires two
parameters,
and n both nonnegative
integers and 
- Obtain the help for the commands surf, contour,
meshgrid, real, and create a 3d plot the real part of
the function z2 where z=x+iy,
on a grid where x=[-2,+2] and y=[-2,+2].
Choose a suitable number of grid points to plot.
- Create a 3d plot of sin(r)/r, where
,
and
with a suitable
number of gridpoints. Try a contour plot, surf plot
and a waterfall plot. Get the help of the command view
and type view(0,90);shading flat.
Back to the Main Page