Replace odd numbers with infinity
Ältere Kommentare anzeigen
I have a code that looks like the following:
C = randi([100,200],1000,1000);
evenIndices = rem(C,2) == 0
allTheEvenNumbers = C(evenIndices)
allTheEvenNumbers = allTheEvenNumbers -1
locations = find(allTheEvenNumbers)
C(locations) = Inf
I am wanting the odd numbers to be replaced by Inf but it is not working. Where am I going wrong?
2 Kommentare
Adam Danz
am 12 Okt. 2019
Note: this is a continuation from
per isakson
am 13 Okt. 2019
Bearbeitet: per isakson
am 13 Okt. 2019
@Adam Thanks, I missed that.
Akzeptierte Antwort
Weitere Antworten (0)
Kategorien
Mehr zu Logical finden Sie in Hilfe-Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!