Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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.

image text in transcribedimage text in transcribed

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 pass

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Repairing And Querying Databases Under Aggregate Constraints

Authors: Sergio Flesca ,Filippo Furfaro ,Francesco Parisi

2011th Edition

146141640X, 978-1461416401

More Books

Students also viewed these Databases questions

Question

x-3+1, x23 Let f(x) = -*+3, * Answered: 1 week ago

Answered: 1 week ago

Question

Experience with SharePoint and/or Microsoft Project desirable

Answered: 1 week ago

Question

Knowledge of process documentation (process flow charting)

Answered: 1 week ago