Replace odd numbers with infinity
이전 댓글 표시
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
Adam Danz
2019년 10월 12일
Note: this is a continuation from
per isakson
2019년 10월 13일
편집: per isakson
2019년 10월 13일
@Adam Thanks, I missed that.
채택된 답변
추가 답변 (0개)
카테고리
도움말 센터 및 File Exchange에서 Logical에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!