MATLAB: Setting min and max values of an array

arraycontrolMATLABmaxmin

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?

Best Answer

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