I have any matrix I need a code such that if the absolute value of a value in the matrix less than 3, then this value equal to zero.
for example if i have the matrix:
A=[-1,4,3;1,5,-7;3,-2,9]
the answer will be:
B=[0,4,0;0,5,-7;0,0,9]
Thank you

 Respuesta aceptada

per isakson
per isakson el 27 de Abr. de 2015
Editada: per isakson el 27 de Abr. de 2015

0 votos

Try
>> B = A;
>> B(abs(A)<=3) = 0
B =
0 4 0
0 5 -7
0 0 9
However, -7 isn't it "less than 3"?

Más respuestas (1)

Categorías

Más información sobre Creating and Concatenating Matrices en Centro de ayuda y File Exchange.

Etiquetas

Preguntada:

el 27 de Abr. de 2015

Editada:

el 27 de Abr. de 2015

Community Treasure Hunt

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

Start Hunting!

Translated by