4

My goal is to change an order three matrix, to an order two matrix simply (perhaps with one line of code) Any idea?

A = rand(256, 256, 3);
B = zeros(256, 256);


for i = 1: size(A, 1)
    for j = 1 : size(A, 2)
        B(i,j) = max(A(i,j, :));
    end
end

1 Answer 1

4

I think this is what you are after:

B = max(A, [], 3);
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.