How to divide a matrix to its maximum value?

조회 수: 5 (최근 30일)
SAKSHAM SHRIVASTAVA
SAKSHAM SHRIVASTAVA 2023년 7월 11일
댓글: SAKSHAM SHRIVASTAVA 2023년 7월 11일
How to divide a matrix to its maximum value?
  댓글 수: 2
Les Beckham
Les Beckham 2023년 7월 11일
You need to more clear about what you mean. Ideally, show a simple example of the input data and the expected result. Include your data and the code you have written so far.
SAKSHAM SHRIVASTAVA
SAKSHAM SHRIVASTAVA 2023년 7월 11일
Lets take a example
A matrix z = [1,2,3;4,5,6;7,8,9]
now I have to divide this whole matrix by 9 which is the maximun value in the matrix.
But if the size of matrix is very large, it is very difficult to find maximum value of the matrix manually and then divide the matrix by this maximum value. So how to do this?

댓글을 달려면 로그인하십시오.

답변 (1개)

Rahul
Rahul 2023년 7월 11일
Hi Saksham,
According to the description given by you, you can follow the following code for the same.
% Example matrix
matrix = [10, 20, 30; 40, 50, 60; 70, 80, 90];
% Find the maximum value
maxValue = max(matrix, [], 'all');
result = matrix / maxValue;
In this way you will be able to divide the whole matrix by the maximum value present in it.
Incase you have matrix of different dimensions,this code can get the maximum value out of a multi dimensional matrix as well. Then you can divide it by the matrix to get the desired result.
Thanks.

카테고리

Help CenterFile Exchange에서 Creating and Concatenating Matrices에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by