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.

 Akzeptierte Antwort

Andrei Bobrov
Andrei Bobrov am 8 Nov. 2011

20 Stimmen

a(a>=5)=5

2 Kommentare

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

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (0)

Kategorien

Mehr zu Data Type Identification finden Sie in Hilfe-Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by