MATLAB: Plotting cell array with empty data colums

cell arrayplot

I've gotten along to debugging my plotting function. Fisrt up to 6 raw multi-data type files are loaded. Then for one parameter, I have up to 6 stored in a cell (x1,y1,x2,y2,…etc), depending on which of the origial files need to be plotted.
I may end up with a cell array like: x1 y1 [] [] x3 y3 x4 y4 [] [] [] []
When I plot, I expect it to plot just x1, y1, x3, y3, x4, y4. When I just have one data set in the array, no matter its poition, everything is fine. If I plot multiple files, I experience odd results.

Best Answer

plot(f{~cellfun(@isempty,f)});