It is possible to use 'polyval' with data containing nan?
    4 ビュー (過去 30 日間)
  
       古いコメントを表示
    
    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
0 件のコメント
採用された回答
  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 Center および File Exchange で Line Plots についてさらに検索
			
	Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!

