How to divide a matrix to its maximum value?
8 次查看(过去 30 天)
显示 更早的评论
How to divide a matrix to its maximum value?
2 个评论
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.
回答(1 个)
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 Center 和 File Exchange 中查找有关 Resizing and Reshaping Matrices 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!