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);
  1 件のコメント
Camila Hashimoto
Camila Hashimoto 2017 年 1 月 9 日
hey, you are the best! thanks ;)

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeLine Plots についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by