Sunday, 15 May 2011

sum - Adding two submatrices in Matlab? -



sum - Adding two submatrices in Matlab? -

i have 5x5 matrix m = magic(5)and must add together 2 sub-matrices of (using thesumcommand) , store ing`, are:

m(1:3,1:3) , m(3:5,3:5)

and wrote this, i', not sure if it's correct,

g=sum(m([1:3,1:3],[3:5,3:5]));

as mentioned in comments, accomplish goal +.

m = magic(5); = m(1:3,1:3); b = m(3:5,3:5); g = + b;

it little complicated if want utilize sum,

c(:,:,1) = a; c(:,:,2) = b; g = sum(c,3);

matlab sum submatrix

No comments:

Post a Comment