MATLAB: Undefined function or variable ‘isnan’

errorisnanMATLAB

I am met with the error "Undefined function or variable 'isnan'" when running this code:
%counter = 1:4
%a is a 220x4 cell
%data is a 220x4 double
for i = size(a, 1)
pairs = [];
pairs(:,1) = counter;
pairs(:,2) = data(i,:);
pairs = pairs(~isnan(pairs(:,2),:));
slope(i) = polyfit(pairs(:,1),pairs(:,2),1);
end
I can't seem to figure out exactly why. Is the way I'm using the NOT operator?

Best Answer

You have
pairs = pairs(~isnan(pairs(:,2),:));
You want
pairs = pairs(~isnan(pairs(:,2)),:);