Computation using cellfun

Cell arrays are useful means of holding various types and sizes of information (as are structs). When manipulations or computations need to be performed on all or a subset of values in a cell array, one useful function that can be utilized is cellfun . Similar to other functions such as structfun or arrayfun, cellfun allows you to apply a predefined or user defined function to each element in the array.

Continue reading

Bookmark and Share

The use of findobj and set for graphics properties

After you create a plot in Matlab, you might need to modify the characteristics of the figure. While many options can be specified during the initial plot command, they can easily be modified later as well using plot handles, and the useful functions of ‘findobj’,'get’ and ‘set’. If you are unclear on some of these commands, or need a refreshers, take a look at our tutorial on plotting .

Continue reading

Bookmark and Share

How to Use Imagesc in Matlab

On Matlab Geeks, we have already covered basic two-dimensional plotting techniques.  We would now like to start covering techniques for plotting three-dimensional data.  One of the easiest and most visually pleasing ways of plotting three-dimensional data onto a 2-D surface is imagesc.  Originally meant to be used with image data, this function is a great tool for plotting 2-D matrices.  Imagesc is different from the image function in that the data is automatically scaled to fit the range of the colormap.  This feature makes representing a matrix with imagesc is far easier than with image.  We recommend using imagesc to plot data from a 2-D matrix. Continue reading

Bookmark and Share

How to Create a Plot with a Date Axis

One of the most common questions for Matlab users is how to plot data on a date axis.  Many times, an analyst will initially use Excel, but then decide that he or she wants more analytical capabilities or plotting options.  Excel has an easy way to plot data on a date axis, but to use a date axis in Matlab requires familiarity with a few functions.  Don’t worry, using Matlab for this task is not that hard and, like most of Matlab’s functions, allows a considerable degree of versatility.

Continue reading

Bookmark and Share