How do I use regexprep to replace final NaN values in a matrix?
조회 수: 6 (최근 30일)
이전 댓글 표시
I have a numeric data stream like this:
NaN NaN NaN 100 102 101 99 102 NaN NaN NaN NaN NaN 101 103 NaN NaN, etc
I'd like to replace the last NaN in each string of NaNs with a zero so it would look like this:
NaN NaN 0 100 102 101 99 102 NaN NaN NaN NaN 0 101 103 NaN NaN
Is this a good regexprep situation or should I do find()?
답변 (2개)
Azzi Abdelmalek
2013년 3월 20일
A=[NaN NaN NaN 100 102 101 99 102 NaN NaN NaN NaN NaN 101 103 NaN NaN]
A(diff(isnan([A 0]))==-1)=0
댓글 수: 0
Jan
2013년 3월 21일
A = [NaN NaN NaN 100 102 101 99 102 NaN NaN NaN NaN NaN 101 103 NaN NaN];
A(strfind(isnan(A), [true, false]) = 0;
댓글 수: 0
참고 항목
카테고리
Help Center 및 File Exchange에서 Operators and Elementary Operations에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!