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.
댓글 수: 0
채택된 답변
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
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 Exchange에서 Creating and Concatenating Matrices에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!