images = {'P1.JPG','P2.JPG','P3.JPG','P4.JPG','P5.JPG','P6.JPG','P7.JPG','P8.JPG','P9.JPG','P10.JPG','P11.JPG','P12.JPG','P13.JPG','P14.JPG','P15.JPG','P16.JPG','P17.JPG','P18.JPG','P19.JPG','P20.JPG','P21.JPG','P22.JPG','P23.JPG','P24.JPG','P25.JPG','P26.JPG','P27.JPG','P28.JPG','P29.JPG','P30.JPG','P31.JPG','P32.JPG','P33.JPG','P34.JPG','P35.JPG','P36.JPG','P37.JPG','P38.JPG','P39.JPG','P40.JPG','P41.JPG','P42.JPG','P43.JPG','P44.JPG','P45.JPG','P46.JPG','P47.JPG','P48.JPG','P49.JPG','P50.JPG','P51.JPG','P52.JPG','P53.JPG','P54.JPG','P55.JPG','P56.JPG','P57.JPG','P58.JPG','P59.JPG','P60.JPG','P61.JPG','P62.JPG','P63.JPG','P64.JPG','P65.JPG','P66.JPG','P67.JPG','P68.JPG','P69.JPG','P70.JPG','P71.JPG','P72.JPG','P73.JPG','P74.JPG','P75.JPG','P76.JPG','P77.JPG','P78.JPG','P79.JPG','P80.JPG','P81.JPG','P82.JPG','P83.JPG','P84.JPG','P85.JPG','P86.JPG','P87.JPG','P88.JPG','P89.JPG','P90.JPG','P91.JPG','P92.JPG','P93.JPG','P94.JPG','P95.JPG','P96.JPG','P97.JPG'};
ix = randi([1,97]);
imagedata = images{ix};
imshow(imagedata);
[num,namePic,raw] = xlsread('DB.xls');
image_names = namePic(2:end,1) ;
image_desc = namePic(2:end,2) ;
pos = 1:length(image_names) ;
idx = strcmpi(images(ix),image_names) ;
idx = pos(idx) ;
title(image_desc(idx)) ;
Best Answer