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.

 採用された回答

Andrei Bobrov
Andrei Bobrov 2011 年 11 月 8 日

20 投票

a(a>=5)=5

2 件のコメント

zhe li
zhe li 2011 年 11 月 8 日
Thank you very much, Andrei.
maede parishani
maede parishani 2023 年 2 月 15 日
Thank you!

サインインしてコメントする。

その他の回答 (0 件)

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by