I'm currently writing a function for a vector where it returns the maximum values and the entire maximum value of the entire matrix.
Eg given the vector A = [3 4 5; 5 6 7]
the vector should return [5 7] and entire maximum is 7
this is my code at the moment
—
function [row_max, matrix_max ] = computeMatrixMax(A)% inputs: A
% A is a matrix (the size is arbitrary
[rows, columns] = size(A);row_max = A(1,1);rows = 1; columns = 1;for i = 1:rows for j = 1: columns if A(i,j) > row_max row_max = A(i,j); end endmatrix_max = A(1,1);for p = 2:numel(A) if A(p) > matrix_max matrix_max = A(p) endend
though it keeps erroring… what am I doing wrong?
EDIT: DON'T WANT TO USE IN-BUILT 'MAX' FUNCTION
Best Answer