MATLAB: Removing entire row in cell array if first column is a NaN

allanycellfunfindisnan

My data matrix (after reading into matlab with xlsread) contains many rows of string and numerical data, and at the end, there sometimes exists several rows of "NaN"s
I want to delete these specific rows but can't seem to do it properly.
I've tried q=cellfun(@(x) all(isnan(x)),myMatrix); myMatrix(q); but the result is no longer a cell
I've tried findNan=isnan(myMatrix(:,1)) to find the index of the row containing the NaN's to kill it, but it gives an error: ??? Undefined function or method 'isnan' for input arguments of type 'cell'.
Any assistance is appreciated! Thanks 🙂

Best Answer

myMatrix( cellfun( @(C) isnumeric(C) && isnan(C), myMatrix(:,1) ), :) = [];