フィルターのクリア

Rescaling a variable with NaNs

5 ビュー (過去 30 日間)
Peter P
Peter P 2019 年 7 月 25 日
回答済み: Stephen23 2019 年 7 月 25 日
I want to rescale my matrix(56,53), it is filled with numbers from 1 to 7 and NaNs. I would like to change the 1 to 7, 2 to 6, 3 to 5 and 5 to 3, 6 to 2, and 7 to 1.
I found this solution https://stackoverflow.com/questions/48542055/reverse-coding-in-matlab but it does not work for me even though I replaced the NaNs with 0.
Any suggestions? Thank you in advance.

採用された回答

Stephen23
Stephen23 2019 年 7 月 25 日
>> M = randi(7,3,5);
>> M(randi(numel(M),1,3)) = NaN
M =
6 7 7 6 4
3 NaN 5 NaN 6
5 4 NaN 2 7
>> Z = 8-M
Z =
2 1 1 2 4
5 NaN 3 NaN 2
3 4 NaN 6 1

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeLogical についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by