MATLAB: How to solve “Subscripted assignment dimension mismatch”

subscripted assignment dimension mismatch

I have two images; imgA and imgB with the size of 43*54*3
I wanted them to display on my screen (1366*768)
I was using the below code to do the same, however it shows me an error say dimention mismatch( sometimes for imgA or imgB)
Please find below code
PS: n is number is trials. img final size is 1366*768
I am using 2016a
if disp_position(n) == 1
LorR{n}= 'Left up';
Img_final(279:322,548:602,:)=imgA;
Img_final(279:322,818:872,:)=imgB;
Img_final(447:490,548:602,:)=imgB;
Img_final(447:490,818:872,:)=imgB;
elseif disp_position(n) == 2
LorR{n}= 'Right Up';
Img_final(279:322,548:602,:)=imgB;
Img_final(279:322,818:872,:)=imgA;
Img_final(447:490,548:602,:)=imgB;
Img_final(447:490,818:872,:)=imgB;
elseif disp_position(n) == 3
LorR{n}= 'Left down';
Img_final(279:322,548:602,:)=imgB;
Img_final(279:322,818:872,:)=imgB;
Img_final(447:490,548:602,:)=imgA;
Img_final(447:490,818:872,:)=imgB;
else
LorR{n}= 'Right down';
Img_final(279:322,548:602,:)=imgB;
Img_final(279:322,818:872,:)=imgB;
Img_final(447:490,548:602,:)=imgB;
Img_final(447:490,818:872,:)=imgA;
end
Please help me solving this problem. I was trying to tackle this last one day but did not successed

Best Answer

Off by one error, 279:322 is 44 elements not 43. Same for all the other indices, you've got one more element than required.
Anyway, why aren't you using montage for this?