if i want to change each value 1 in a matrix to 0 how to do that?

a=[1 2 3;1 3 3;2 1 2]
is there a function that make a as below
b=[0 2 3;0 3 3;2 0 2]

2 comentarios

Is this homework?
This can be solved with a combination of loops (for) and conditional statements (if), or in a syntactically simpler way with logical indexing.
nop i just want a function some reduced thing instead of using loops

Iniciar sesión para comentar.

 Respuesta aceptada

b = a;
b(b==1) = 0;

3 comentarios

perfect thanx alot
Please accept an answer if it helped you.
sure i just forgot ,, sorry ,, thanx again

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre Loops and Conditional Statements en Centro de ayuda y File Exchange.

Etiquetas

Preguntada:

el 4 de Dic. de 2013

Comentada:

el 7 de Dic. de 2013

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by