MATLAB: How to get multiple boxplots onto one figure, with NaNs in the mix

boxplotfigurenanplotting

Hi,
I've been trying to get 3 plots on one figure and have mostly gotten there, but my code keeps throwing the error: "G must be the same length as X or the same length as the number of columns in X," even though these 2 variables are the same lengths. I can't help but think it's the NaNs, even though I've read that boxplot treats them correctly. Code to follow:
First, I created these vectors as I am compiling group data and generating a mean. With that mean, I want to plot in terms of the scalae (which is the ST, SM, and SV variables).
meanampST = [meanampST peakmeanST]; meanampSM = [meanampSM peakmeanSM]; meanampSV = [meanampSV peakmeanSV];
After those are filled:
group = [ones(size(meanampST));2*ones(size(meanampSM)); 3*ones(size(meanampSV))]; x = cat(1,meanampST,meanampSM,meanampSV); boxplot(x,group);
..and then I get the error. For reference:
x =
0.1043 0.1488 NaN 0.0628 0.1959 0.2604 0.0674 0.0477
0.2905 0.2177 0.0814 0.0793 0.3609 0.1885 NaN 0.0478
NaN NaN 0.0671 0.1126 NaN NaN NaN 0.1584
group =
1 1 1 1 1 1 1 1
2 2 2 2 2 2 2 2
3 3 3 3 3 3 3 3
UGGH! Thank you so much!

Best Answer

Just a small change needed:
boxplot(x(:), group(:))