Rescaling a variable with NaNs
5 visualizzazioni (ultimi 30 giorni)
Mostra commenti meno recenti
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.
0 Commenti
Risposta accettata
Stephen23
il 25 Lug 2019
>> 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 Commenti
Più risposte (0)
Vedere anche
Categorie
Scopri di più su Logical in Help Center e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!