Question: MATLAB Develop a Matlab function to normalize a matrix by dividing each row by the maximum absolute value in the row so that the maximum
MATLAB
Develop a Matlab function to normalize a matrix by dividing each row by the maximum absolute value in the row so that the maximum element in each row is 1 WITHOUT using the max function
The idea is to enter any matrix, it finds the largest value (that is abs value), and then every value in the matrix is divided by that max abs value. I will attach a picture to clarify. The solution needs to be output as a matrix
my code: Feel free to write something different other than this. I think I may have confused myself which is why I say try your own method !
function [Norm_mat] = mat(a) [x,y] = size(a); max_row = zeros(1,x); for i = 1:x for j = 1:y for k = 1:y if a(i,j)> a(i,k) max_row(i) = a(i,j); end end end end
Norm_mat = a./max_row';
end
----------------------------------------------
>>mat([1 2 7 3 5])
ans =
0.2000 0.4000 1.4000 0.6000 1.0000
---------------------------------------------
The ans should of been 0.1428 0.2857 1.0000 0.4285 0.7142

# # 4 - Basically what we are trying to output kinds max value in ales form [1,2,2, 3,5 divide every # by that [11, 2/7 ,7/7, 3/7, 5/7 mor value
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
