Skip to content

Instantly share code, notes, and snippets.

@shaybensasson
Created March 4, 2015 09:03
Show Gist options
  • Save shaybensasson/ee64de41b52fd83f3ec5 to your computer and use it in GitHub Desktop.
Save shaybensasson/ee64de41b52fd83f3ec5 to your computer and use it in GitHub Desktop.
remove NaN columns or rows
% see http://www.mathworks.com/matlabcentral/answers/68510-remove-rows-or-cols-whose-elements-are-all-nan
out = A(:,any(~isnan(A))); % for columns
out = A(any(~isnan(A),2),:); %for rows
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment