Setting min and max values of an array

Hi,
I have the following array A=(1:5:500).
If the value in the array is less than max(A)/2 I need the value to be set to max(A)/2. After that I need it to continue to the final value of the array.
Can anyone suggest a solution?

 채택된 답변

KSSV
KSSV 2017년 3월 7일

0 개 추천

A = rand(1,500) ;
id = find(A<max(A)/2) ;
A(id(1):end) = max(A)/2 ;

추가 답변 (0개)

카테고리

도움말 센터File Exchange에서 Matrix Indexing에 대해 자세히 알아보기

제품

질문:

Y.U
2017년 3월 7일

댓글:

2021년 5월 19일

Community Treasure Hunt

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

Start Hunting!

Translated by