MATLAB Write a function called biggestnumber that takes an a

MATLAB: Write a function called biggest_number that takes an at most two-dimensional matrix A as its sole input. The function returns the largest element of A. You are not allowed to use the built-in max function.

Solution

function a =hw3_problem2(intput)

% Number of rows and columns of array
[r,c] = size(input);


% Taking maximum values as a first element for reference
maximum = input(1,1);

% Logic to find maximum element

for i=1:r
  for j=1:c
   if(maximum <= input(i,j))
    maximum = input(i,j);
         end
  end
end
a = maximum;
end

MATLAB: Write a function called biggest_number that takes an at most two-dimensional matrix A as its sole input. The function returns the largest element of A.

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site