calculate data based on previous values and replace it at negative and zeros values
이전 댓글 표시
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일
편집: Image Analyst
2018년 7월 4일
Not the average of the data on each side of the bad data? Just on the previous side? OK, but average how many on the previous side only? This is easy to do with conv() and logical indexing, so just try it. Even easier if you have the Image Processing Toolbox. Let me know if you can't figure it out.
KSSV
2018년 7월 4일
Your data has negative values in the first index also i.e 1:17 values are negative..with what you want to replace them?
MUKESH KUMAR
2018년 7월 4일
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)?
MUKESH KUMAR
2018년 7월 4일
편집: MUKESH KUMAR
2018년 7월 4일
답변 (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') ;
카테고리
도움말 센터 및 File Exchange에서 Logical에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!
