I’m trying to write the max function of matlab:
B = max(A,B);
Is it correct?
for i=1:size(A,1)
for j=1:size(A,2)
if A(i,j) > B(i,j)
B(i,j) = A(i,j);
end
end
end
thank you!
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
if you mean that
B = max(A,B)should output a matrix containing at each index (i,j) the largest of either A(i,j) or B(i,j), then yes, it is correct (if you supply it with two-dimensional matrices A and B withsize(A)>=size(B))The standard max function however does not exactly work like that. For example it can also handle higher dimensional matrix input, you can specify along which dimension you want to calculate maximum,…