We can use Matlab’s own command to interrogate the data; these commands find use in
the M-files that store subroutines. An example routine is called after this. This subroutine is
stored in a file called invert.m and is a function that inverts brightness by subtracting the
value of each point from the array’s maximum value. The code is illustrated in Code 1.7.
Note that this code uses for loops, which are best avoided to improve speed, using Matlab’s
vectorized operations (as in Mathcad). The whole procedure can be implemented by the
command inverted=max(max(pic))-pic. One of Matlab’s assets is a ‘profiler’ which
allows you to determine exactly how much time is spent on different parts of your programs.
There is facility for importing graphics files, which is actually rather more extensive (i.e. it
accepts a wider range of file formats) than available in Mathcad. When images are used, this
reveals that unlike Mathcad, which stores all variables as full precision real numbers, Matlab
has a range of datatypes. We must move from the unsigned