How to create a matrix that includes the elements of other matrices that happen to meet a certain condtion?

2 views (last 30 days)
Really new at this stuff, trying to do a problem for homework where I am supposed to create two equal size matrices and create a new equally sized matrix where each element is the larger of the corresponding elements of the two original matrices. I need to do the same problem using different loops and also not using loops but I am just really stuck on getting the greater of two corresponding elements and making a new equally sized matrix out of them where each element is in the spot. If (2,4) of matrix one is a bigger number it needs to be (2,4) of the third matrix) .I can create functions that give me the numbers I want but I just can't figure out the rest. Any insight would be appreciated.

Accepted Answer

Walter Roberson
Walter Roberson on 9 May 2015
if A(J,K) > B(J,K)
C(J,K) = A(J,K);
else
C(J,K) = B(J,K);
end

More Answers (0)

Categories

Find more on Startup and Shutdown in Help Center and File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!