How to replace numbers in an array

Could anybody help me solve the problem please? I have a sample array a=[3 2 5 7 4 8 2 5], I would like to replace all numbers greater than 5(>5) to be 5, the expected result should be a=[3 2 5 5 4 5 2 5]. Thank you very much.

 Respuesta aceptada

Andrei Bobrov
Andrei Bobrov el 8 de Nov. de 2011
a(a>=5)=5

2 comentarios

zhe li
zhe li el 8 de Nov. de 2011
Thank you very much, Andrei.
maede parishani
maede parishani el 15 de Feb. de 2023
Thank you!

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre Data Type Identification en Centro de ayuda y File Exchange.

Etiquetas

Preguntada:

el 8 de Nov. de 2011

Comentada:

el 15 de Feb. de 2023

Community Treasure Hunt

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

Start Hunting!

Translated by