Date: Mar 20, 2013 6:23 PM
Author: Paul
Subject: streamline dereferencing of cell array into argument list
If I have column vectors x & y of the same length, I know that I can

plot a series of points via plot(x,y). Alternatively, I can plot each

vector as a series of points against their indexes via plot([x y]).

But let's say that I'm interested in the first case.

Now if I wanted a quick and dirty way to plot just a handful of points

[x1,y1], [x2,y2], and [x3,y3] without writing many statements, I can

use:

myPts = mat2cell( [x1 y1; x2 y2; x3 y3], [3], [1 1] )

plot( myPts{:} );

This is exactly the 2-vector form above, but the code keeps each pair

of x & y values together instead of handling the x-vector separately

from the y-vector. In many cases, that kind of visual binding is

helpful when I'm quickly hacking through various coding possibilites

in an exploratory manner because I have the coordinates in my head as

numerical pairs. Granted, the need to think about the 2nd & 3rd

arguments to mat2cell makes it questionable whether this is really

more streamlined, but let's ignore that for now.

My question is whether there is a more direct way of getting the

argument list in the 2nd statement. In the example above, I need to

assign it to myPts before dereferencing the cells. It's too bad we

can't do something like

plot( mat2cell( [x1 y1; x2 y2; x3 y3], [3], [1 1] ){:} )