Subtract elements greater than a threshold?

6 ビュー (過去 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 Center および File ExchangeMatrix Indexing についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by