MATLAB: Image tiling & combining images

combiningimagestiling

Hello. Quite new to the MATLAB, trying to make an image with 4 different images, where each side(upperwest,uppereast,lowereast,lowerwest)is a different image. Like one of those Andy Warhol photographs. But I keep getting this error when I try to run the function:
>> imshow(TileImage(image1,image2,image3,image4))
Subscripted assignment dimension mismatch.
Error in TileImage (line 16)
NewImage(1:floor(end/2),floor(end/2)+1:end,:) =
image2(:,:,:);
Here is my function:
*function [ NewImage ] = TileImage( image1,image2,image3,image4 )
%TileImage takes an input for an array of four tiled image.
% TileImage is an RGB matrix made out of four input image matrices.____
rows = size(image1, 1);
columns = size(image1, 2);
layers = size(image1, 3);
% A matrix to make the image into a matrix of zeros to make all images
% equally sized.
NewImage = uint8(zeros(2.*rows,2.*columns,layers));
% To make all images the same size and place them into a specific
% quadrant.
NewImage(1:floor(end/2),1:floor(end/2),:) = image1(:,:,:);
NewImage(1:floor(end/2),floor(end/2)+1:end,:) = image2(:,:,:);
NewImage(floor(end/2)+1:end,1:floor(end/2),:) = image3(:,:,:);
NewImage(floor(end/2)+1:end,floor(end/2)+1:end,:) = image4(:,:,:);
end*
Am I missing something? Maybe in the command window? All 4 images are already defined in CW. Any help will be much appreciated!!

Best Answer

Like I told you before, here, one of your images is not the same size as one of the others. From the error message, I can tell that image2 is not the same size as image1.