title: how to add 3 matrices with one dimension same for all and other dimension different in matlab?
body: <p>I have matrices A=2x2 B=2x4 C=2x2 I want result in a matrix D=2x16 for example</p>
  
  <pre><code>A=[1 3;
     2 4]
  B=[3 2 4 2;
     4 3 6 3]
  C=[4 5;
     7 5]
  D=[(1+3+4) (1+3+5) (1+2+4) (1+2+5) (1+4+4) (1+4+5) (1+2+4) (1+2+5) (3+3+4) (3+3+5) (3+2+4) (3+2+5) (3+4+4) (3+4+5) (3+2+4) (3+2+5);
     (2+4+7) (2+4+5) (2+3+7) (2+3+5) (2+6+7) (2+6+5) (2+3+7) (2+3+5) (4+4+7) (4+4+5) (4+3+7) (4+3+5) (4+6+7) (4+6+5) (4+3+7) (4+3+5)]
  </code></pre>
  
  <p>means that row wise elements are added in resultant. I have a code in which A=2x1 but I can understand how to mold it according to A=2x2 the code is given below</p>
  
  <pre><code>[rows,col_B]=size(B);
  [~,col_C]=size(C);
  result=zeros(rows,col_B*col_C);
  for i=1:col_B
      for  j=1:col_C
          result(:,(i-1)*col_C+j)=A+B(:,i)+C(:,j);
      end
  end
  </code></pre>
  
  <p>can anybody tell me the syntax for the output RESULT in this code?</p>