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

4 次查看(过去 30 天)
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 中查找有关 NaNs 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by