MATLAB: Remove empty cells and values for correlations

correlationempty cellMATLAB

Hi,
I have a 32×2 cell and I would like to do a correlation for the values in the first column with the values in the second column. However, there are blank cells in the first column. Could anyone help me find a way to do a correlation that excludes all the blank cells and their corresponding values in the second column?
Thanks!

Best Answer

Does this do what you want?
CData = {45 20; 16 32; [] 10; 17 6};
CE = cellfun(@isempty, CData(:,1));
Data = cell2mat(CData(~CE,:));
[R, P] = corrcoef(Data)