MATLAB: Ignore nan values in plotting

ignore nan values

Hi!
I need your help please!
I have to plot columns with nan values. I want to ignore the nan. I have the table LOGIR who contains 2048 columns and the table XMEAN with one column. The XMEAN has no nan values. The LOGIR has nan. I want to plot XMEAN with each column of the LOGIR and then i do fitting linear. The problem is that the equation of line is y=nanx+nan, because include the nan values. How can i ignore the nan values??
My script is:
for k=159:100:2048
p=polyfit(XMEAN,LOGIR(:,k),1);
yfit=polyval(p,XMEAN);
figure(k);
plot(XMEAN,LOGIR(:,k),'.',XMEAN,yfit,'r');
gtext(['y=',num2str(p(1)),'x+',num2str(p(2))])
xlabel('airmass')
ylabel('logirradiance')
print(sprintf('Figure(%d).bmp',k), '-dbmp')
end
Thank you

Best Answer

It works!! Thank you very much!