title: How to Append pictures in Matlab?
body: <p>I want to do this pseudocode in a system without imagemagick but I have Matlab 2016a and Java in the system</p>
  
  <pre><code>convert 1.png 2.png +append result.png
  </code></pre>
  
  <p>Assume you want to concatenate in a loop like the following such that dimensions may not match. 
  However, all objects 1,2,...,N have exactly the same dimensions. 
  The following loop, however, concatenates two pictures at the same time, making the dimensions different with subsequent images: bigImage vs new image. </p>
  
  <pre><code>iterationCounter=1;
  
  result=0;
  while(iterationCounter &lt; 3)
      imgRGB=imread(filenamePng); % Images 1,2, ..., N have same dimensions.
  
      if (result==0)
          result=imgRGB;
      end
  
      % http://stackoverflow.com/a/35915990/54964
      if (ismatrix(result(:,:,1)))
          heightRatio=size(result,1)/size(imgRGB,1);
          wantedSize=int16([size(result,1), size(imgRGB,2)*heightRatio]);
          imgResized=imresize(imgRGB, wantedSize);
          result=[result, imgResized];
      end
  
      iterationCounter=iterationCounter+1;
  
  end
  </code></pre>
  
  <p>where output is an empty picture. </p>
  
  <hr>
  
  <p>How can you do the horizontal appending of the images in Matlab/Java?</p>