Subtract elements greater than a threshold?

조회 수: 7 (최근 30일)
Eric Beamesderfer
Eric Beamesderfer 2020년 1월 23일
댓글: Eric Beamesderfer 2020년 1월 23일
I have a 2048x10000 double precision dataset. Most values range from 0 to ~5000, but there are scattered values exceeding 1,000,000. After reading the manual for the instrument, I found that for numbers greater than 524287 (2^19 - 1) you're supposed to substract 1048576 (2^20). I had thought to index the data (ind = (test > 524287)) and then subtract the values from those indexed elements but have been unable to make it happen, often receiving the error: "Unable to perform assignment because the left and right sides have a different number of elements."

채택된 답변

Walter Roberson
Walter Roberson 2020년 1월 23일
mask = YourArray > 2^19 - 1;
YourArray(mask) = YourArray(mask) - 2^20;
  댓글 수: 1
Eric Beamesderfer
Eric Beamesderfer 2020년 1월 23일
Thank you, Walter. Appreciate your time and help!

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Matrix Indexing에 대해 자세히 알아보기

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by