Search All of the Math Forum:

Views expressed in these public forums are not endorsed by NCTM or The Math Forum.

Notice: We are no longer accepting new posts, but the forums will continue to be readable.

Topic: Merging multiple matrices
Replies: 4   Last Post: May 9, 2013 10:56 AM

 Messages: [ Previous | Next ]
 Bruno Luong Posts: 9,822 Registered: 7/26/08
Re: Merging multiple matrices
Posted: May 9, 2013 9:57 AM

"Martijn van Sebille" wrote in message <kmg978\$ljp\$1@newscl01ah.mathworks.com>...
> Dear,
>
> I am trying to efficiently merge multiple matrices, combining their maximal values. For example:
> If A = [1 1 2; 1 2 1; 2 1 1] and B = [3 1 1; 1 3 1; 1 1 3], then their maximal values combined would be: C = [3 1 2; 1 3 1; 2 1 3].

C = max(A,B)

If you have several, e.g., A1, A2, ...., A100, consider the for loop or using 3d array as temporary variable:

C = { A1 , A2, ... A100 }
C = max(cat(3,C{:}),[],3);

% Bruno

Date Subject Author
5/9/13 Martijn van Sebille
5/9/13 Bruno Luong
5/9/13 Martijn van Sebille
5/9/13 Steven Lord
5/9/13 Martijn van Sebille