calculate data based on previous values and replace it at negative and zeros values
1 回表示 (過去 30 日間)
古いコメントを表示
there is different data in the column in excel (REACTIVE_Y_PH), which has some negative and zeros values also, these values should be replaced by calculating the average of previous data and replace them.
5 件のコメント
Image Analyst
2018 年 7 月 4 日
What were the "last" 5 values when the first few are to be replaced? There are no elements at indexes -4 to 0. Or did you mean the "last" ones at the other end of the array, like from vec(end-4:end)?
回答 (1 件)
KSSV
2018 年 7 月 4 日
[num,txt,raw] = xlsread('sample.xls') ;
data = cell2mat(cellfun(@str2num,txt(:,2),'un',0)) ;
%%fill negative and zeros
idx = data<=0 ;
data(idx) = NaN ;
data = fillmissing(data,'previous') ;
参考
カテゴリ
Help Center および File Exchange で Logical についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!