MATLAB: Plotting cell array with empty cells – changing linespec

plot

I have up to 6 data pairs stored in a cell array.
f={x1 y1 x2 y2 x3 y3 x4 y4 x5 y5 x6 y6}
However, it many not always be all 6 data pairs, and I might end up with:
f={[] [] x2 y2 [] [] [] [] x5 y5 [] []}
It was shown to me that by using:
h=plot(f{~cellfun(@isempty,f)},'o','MarkerSize',1.5)
That empty cells are ignored. The data is plotted fine, but the linespec properties are not being applied to all data, only the last data series plotted.
Additionally,trying to change the marker edge and face color results in only the last handle being modified.
set(h(1),'MarkerEdgeColor','r','MarkerFaceColor','r')
set(h(2),'MarkerEdgeColor','y','MarkerFaceColor','y')
What am I missing?
Also, one issue that seems important, using this method, will there always be 6 handles, even if some are "blank" because their associated cells are empty? Is it possible to know that x3 y3 will always be f(3)?

Best Answer

If you use:
f{~cellfun(@isempty, f)}
The empty cells are not ignore, but they are not forwarded to PLOT at all. PLOT has no information, that there have been empty cells before.
Instead of removing the empty cells, you could insert Inf values. They are considered by PLOT, but do not produce a visible line.
BTW. cellfun('isempty', C) is much faster than cellfun(@isempty, C).