How about expanding the two inputs to generate matrices with matching dimensions, assuming A(1,1) lines up with B(1,1)
Asize=size(A);
Bsize=size(B);
Csize=max(Asize,Bsize);
Anew=zeros(Csize);
Bnew=zeros(Csize);
Anew(1:Asize(1),1:Asize(1,2))=A;
Bnew(1:Bsize(1),1:Bsize(1,2))=B;
S=Anew-Bnew;
Alternatively trim them to the same size after finding the size of the overlap,
Asize=size(A);
Bsize=size(B);
Csize=min(Asize,Bsize);
Anew=A(1:Asize(1),1:Asize(1,2));
Bnew=B(1:Asize(1),1:Bsize(1,2));
S=Anew-Bnew;
1 Comment
Direct link to this comment
https://se.mathworks.com/matlabcentral/answers/159598-hi-every-one-is-there-any-way-how-to-subtradt-two-matrices-of-different-dimension-let-say-a-424x54#comment_244742
Direct link to this comment
https://se.mathworks.com/matlabcentral/answers/159598-hi-every-one-is-there-any-way-how-to-subtradt-two-matrices-of-different-dimension-let-say-a-424x54#comment_244742
Sign in to comment.