MATLAB: How to rewrite the maximum element of an array by an avarage

MATLABrewrite an array

I have an array of 100 random numbers and i need to detect the maximum value of an array and then replace it by mean value of an array.
I have no idea how to do it, help please.

Best Answer

So, if I have interpreted your question correctly then you have an array (say A) and you wish to find the maximum valued element in A. Once found you then want to replace that maximum element with the mean of the elements in A? If that is right then you can do that with:
A(find(A==max(A)))=mean(A);
If that's not what you wanted then you may need to provide some more details on what exactly you want this to do.