how to find maximum value from a matrix then add a value to it and then replace that in the same matrix?

1 回表示 (過去 30 日間)
I have a matrix a=rand(4,10), 1)i want to find the maximum or the highest value in matrix a. 2)add 0.001 to that highest value 3)replace the existing highest value with this added new value without changing any other value
can it be done????
please help me... i am too bad in matlab.

採用された回答

W. Owen Brimijoin
W. Owen Brimijoin 2014 年 6 月 13 日
This ought to do the job!
a=rand(4,10);
a(a==max(a(:))) = a(a==max(a(:)))+0.001;
  3 件のコメント
W. Owen Brimijoin
W. Owen Brimijoin 2014 年 6 月 13 日
Sure thing! Mind you, if there is more than one entry in your array that each happen to be equal to the maximum value, then that code will add 0.001 to both of them. Be warned!

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

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeCreating and Concatenating Matrices についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by