It is possible to use 'polyval' with data containing nan?

조회 수: 4 (최근 30일)
Camila Hashimoto
Camila Hashimoto 2017년 1월 9일
댓글: Camila Hashimoto 2017년 1월 9일
Hi, I want to plot the trend line of 'fice'(856x1), but it has 'nan' from 1:214. When I use 'polyval' the function does not plot the trend line, because it has 'nan's' ...
If I manually put the trend line using 'Tools>Basic Fitting' I can plot the trend line, but it starts from '1' and I want it to start from the '215'
Does anyone have an idea to help me? thanks :)
this is my code...
figure;
aa=[1:(214*4)];
plot(aa',fice,'c');
hold on ;
my_poly=polyfit(aa',fice,1);
X2=215:856; % X data range
Y2=polyval(my_poly,X2);
plot(X2,Y2,'r');%trend line
hold on
plot(Dib,'b'); %plot das áreas normais
hold off
PS: sorry if I have English errors

채택된 답변

Walter Roberson
Walter Roberson 2017년 1월 9일
mask = isnan(fice);
t_aa = aa(~mask);
t_fice = fice(~mask);
my_poly = polyfit(t_aa, t_fice, 1);

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Line Plots에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by