How to replace all odd numbers with infinity using find()
11 visualizzazioni (ultimi 30 giorni)
Mostra commenti meno recenti
timetry2
il 11 Ott 2019
Commentato: Adam Danz
il 12 Ott 2019
I have a code that looks like this: C = randi([100,200],1000,1000);
How would I replace all the odd numbers with infinity using the find() function. I read up on find but I am unsure how to replace just the odd numbers.
Thank you in advance
Risposta accettata
Walter Roberson
il 11 Ott 2019
locations = find( Value_Is_Odd(C) );
where Value_Is_Odd is a function or expression that you write that takes in an array of values and returns a logical array of which entries are odd.
Hint: rem(), mod()
Più risposte (0)
Vedere anche
Categorie
Scopri di più su Characters and Strings 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!