let small numbers in Matrix be zero

Hello, I would like a function that:
example A=[100,16; 5,10]
I would like to make a function f with a threshold=15 such that f(A)=[100,16;0,0]
i.e. all the number below threshold become zero
Any idea? Thank you!

 Respuesta aceptada

Sean de Wolski
Sean de Wolski el 1 de Mayo de 2013
A(A<15) = 0;
Use logical indexing.

2 comentarios

Tiger
Tiger el 1 de Mayo de 2013
Thank you, Sean! Your reply is so fast
Milena Telecka
Milena Telecka el 22 de Abr. de 2020
Great!

Iniciar sesión para comentar.

Más respuestas (0)

Etiquetas

Preguntada:

el 1 de Mayo de 2013

Comentada:

el 22 de Abr. de 2020

Community Treasure Hunt

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

Start Hunting!

Translated by