recode the missing values equal to the preceding recorded value
    5 ビュー (過去 30 日間)
  
       古いコメントを表示
    
hello, 
I am doing assienment and having some problem
there is a matrix:
anuual_CO2 = [ 1990 339; 1991 339.1; 1992 338.8; 1993 -999; 1994 339.5; 1995 338; 1996 -999; 1997 -999; 1998 -999; 1999 339.5; 2000 337.9]
in this matrix, it should recode  '-999' which are missing values. 
I need to draw a plot, set missing values equal to the preceding recorded value
how to set -999 as the previous numbers in the plot without type the number dierectly
thank you for helping in advance
0 件のコメント
回答 (3 件)
  Guillaume
      
      
 2019 年 9 月 1 日
        The easiest way is to use fillmissing with the appropriate option, after having replaced the -999 by NaN.
0 件のコメント
  R.G.
      
 2019 年 9 月 1 日
        Hello! You can use following code:
a = [ 1990 339; 1991 339.1; 1992 338.8; 1993 -999; 1994 339.5; 1995 338; 1996 -999; 1997 -999; 1998 -999; 1999 339.5; 2000 337.9];
for i = 1:length(a)
    if a(i,2) == -999 && i > 1
        a(i,2) = a(i-1,2);
    end
end
0 件のコメント
  Andrei Bobrov
      
      
 2019 年 9 月 1 日
        lo = anuual_CO2(:,2) ~= -999;
x = anuual_CO2(lo,2);
anuual_CO2(:,2) = x(cumsum(lo));
0 件のコメント
参考
カテゴリ
				Help Center および File Exchange で NaNs についてさらに検索
			
	Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!


