Extra tips on sparse matrices in Matlab
We use some simple examples of sparse matrices in the course. They come
from finite difference approximations of twodimensional partial
differential equations.
A twodimensional grid is generated by the routine
G=numgrid(R,ne)
where R is the region chosen and ne is the length of one edge.
The call
A=delsq(G);
gives the matrix of a five point finite difference approximation of the
Laplace operator. Its size is n the number of points in the region R
used when calling numgrid.
I have made a routine v2g that takes a n vector
and distributes it over a grid generated by numgrid. This is usable for
showing data and solutions. See spexample.m
where a simple problem is solved.