MATLAB: How to compare two proportions

chi-squarestatisticsStatistics and Machine Learning Toolbox

I have a vector of x1=[0 1 1 0 1 0 … 1 0 1] and a cell array of string x2={'Condition A' 'Condition A' 'Condition B'….. 'Condition A' 'Condition B' 'Condition B' 'Condition A}.
How can I test if the proportion of "1" is different in Condition A versus Condition B ?
I tried using crosstab() but I am unsure how to set up the data. It looks like crosstab(x1,x2) expects x1 and x2 to be grouping variables. The x1 I have is a response variable.
How should i set up my data for crosstab? Is there another function which would take counts or a binary response variable? Maybe an equivalent of the R function prop.test() ?

Best Answer

Since I could not find a build-in function for my purpose I ended up writing this little function: http://www.mathworks.com/matlabcentral/fileexchange/45966-compare-two-proportions-chi-square