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

 채택된 답변

Fani
Fani 2014년 10월 8일

0 개 추천

It works!! Thank you very much!

댓글 수: 1

dpb
dpb 2014년 10월 8일
Of course it works... :)
If it solved the problem, please Accept the answer so other folks know the subject is resolved...

댓글을 달려면 로그인하십시오.

추가 답변 (1개)

dpb
dpb 2014년 10월 8일

2 개 추천

In your loop over the columns
for k=159:100:2048
p=polyfit(XMEAN,LOGIR(:,k),1);
yfit=polyval(p,XMEAN);
handle the NaNs before trying to fit...
for k=159:100:2048
ix=isfinite(LOGIR(:,k)); % indices of the non-NaN (finite) values
x=XMEAN(ix); y=LOGIR(ix,k); % save in a temporary array
p=polyfit(x,y,1);
yfit=polyval(p,x);
...

카테고리

도움말 센터File Exchange에서 NaNs에 대해 자세히 알아보기

질문:

2014년 10월 8일

댓글:

dpb
2014년 10월 8일

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by