How do I replace Matrix elements
14 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
Liam Bouchereau
el 27 de Oct. de 2020
Given a matrix A replace elements not equal 0 and not equal 1 by 5. Use disp() function to print out the resulting array.
So far I've got
A(A~=0) = 5;
disp(A);
but do not know how to make it 0 AND 1.
2 comentarios
KSSV
el 27 de Oct. de 2020
When you use ~=0 and replace those with 5, the elements whch have 1 also will be eplaced by 5 right?
Respuesta aceptada
Sudhakar Shinde
el 27 de Oct. de 2020
Editada: Sudhakar Shinde
el 27 de Oct. de 2020
Try this:
A((A>1)|(A<0))=5
5 comentarios
Ver también
Categorías
Más información sobre Matrix Indexing en Help Center y File Exchange.
Productos
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!