Question
The question is 'Write a function computeMatrixMax that will take a matrix as input, and return the maximum values of each row ...' I finish
The question is 'Write a function computeMatrixMax that will take a matrix as input, and return the maximum values of each row ...'
I finish the question but the Matlab keeps showing "ans=..." so it cannot pass the student Test. I want to know what I do wrong, what to change OR show me a brand new expression to solve this question. Thank you a lot. It frustrates me so much.
function [row_max matrix_max] = computeMatrixMax(A)
%Input:
%A - a is a matrix (the size is arbitrary)
%Output:
%row_max - a vector that contains the maximum value of each row matrix_max - the maximum value of the matrix
[rows, columns] = size(A);
row_max=size(rows);
for i = 1:rows
row_max(i) = A(i,1);
for j = 1:columns
if A(i,j)>row_max
row_max(i)=A(i,j);
end
end
end
disp(row_max);
matrix_max=A(1,1);
for p = 2:numel(A)
matrix_max = A(p);
end
disp(matrix_max);
end
Write a function computeMatrixMax that will take a matrix as input, and return the maximum values of each row (as a vector) and the maximum value of the entire matrix. Following is the function signature function [row max matrix_max] -computeMatrixMax(A) Input: A - a is a matrix (the size is arbitrary.) Outputs row max - a vector that contains the maximum value of each row matrix max - the maximum value of the matrix For example if, 2 4 7 then the function should return row_max matrix max - Note: You must use loops to iterate through the matrix and compute the required values, rather than using MATLAB built-in functions such as, max. If you do not use loops, you will not receive any marks for the test output, even if test cases pass Write a function computeMatrixMax that will take a matrix as input, and return the maximum values of each row (as a vector) and the maximum value of the entire matrix. Following is the function signature function [row max matrix_max] -computeMatrixMax(A) Input: A - a is a matrix (the size is arbitrary.) Outputs row max - a vector that contains the maximum value of each row matrix max - the maximum value of the matrix For example if, 2 4 7 then the function should return row_max matrix max - Note: You must use loops to iterate through the matrix and compute the required values, rather than using MATLAB built-in functions such as, max. If you do not use loops, you will not receive any marks for the test output, even if test cases passStep by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started