MATLAB: Why can not read images with structures from the folder with different resolution ?

structures

I am reading some images from my folder. I am using structures but If I read from my folder first image all is ok and the FOR statement is ended due to is error message matlab shows:
??? Index exceeds matrix dimensions.
Error in ==> select_part_img at 26
images_part=images_set(1,i); img=imread(images_part.name);
What is problem ? How can I solve this problem ? In my folder are images with different resolution.

Best Answer

Your line
[img_num,no_used]=size(images_set);
is probably incorrect. images_set will be a structure array vector: one of its two dimensions is going to be 1, probably its second dimension, leading to no_used being 1
When "i" is 2, your line
images_part=images_set(1,i);
is going to be incorrect: it is the first dimension that increases. You need
images_part=images_set(i,1);
Better yet, ignore rows vs columns by using
img_num = length(images_set);
and
images_part=images_set(i);