How to replace all odd numbers with infinity using find()
3 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
timetry2
el 11 de Oct. de 2019
Comentada: Adam Danz
el 12 de Oct. de 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
1 comentario
Respuesta aceptada
Walter Roberson
el 11 de Oct. de 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()
Más respuestas (0)
Ver también
Categorías
Más información sobre Characters and Strings en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!