RMS Function Returns NAN
조회 수: 36 (최근 30일)
이전 댓글 표시
I am using the 'rms' function to calculate root mean squared values. For certain portions of data, the function returns NAN. There is good, non-zero data in the array i'm inputting (2000 data points all non-zero). I know how to calculate rms values myself, but for the sake of learning, i would like to know why this is happening.
댓글 수: 0
채택된 답변
Greg Dionne
2019년 6월 11일
It's likely you have NaN in your input, or your input is an empty vector.
If you wish to exclude NaN values from computation, then you can try:
sqrt(mean(x .* x, 'omitnan'))
Hope this helps,
-Greg
추가 답변 (0개)
참고 항목
카테고리
Help Center 및 File Exchange에서 Logical에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!