Hi. I random the images into the axes already now. In the excel file I have list the file image name with the image names in the next column. I would like to get the image name in the second row from the excel file and display it in the textbox. For example if I get P1.jpg it will display rock but if I get P2.jpg it will display paper. Can someone please help me? Thank you.
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');

댓글 수: 2

Image Analyst
Image Analyst 2017년 2월 5일
You forgot to attach db.xlsx, so I doubt people are going to do much to help you until then. In the meantime, learn how to access cell arrays by reading the FAQ.
Jitti Somsiri
Jitti Somsiri 2017년 2월 6일
Sorry I did not attach the excel file. Here it is.

댓글을 달려면 로그인하십시오.

 채택된 답변

KSSV
KSSV 2017년 2월 6일
편집: KSSV 2017년 2월 6일

0 개 추천

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');
%%get the description of image
image_names = namePic(2:end,1) ; % image names
image_desc = namePic(2:end,2) ; % image description
pos = 1:length(image_names) ; % serial number of images of excel
idx = strcmpi(images(ix),image_names) ; % compare the image names
idx = pos(idx) ; % get the position of image name
title(image_desc(idx)) ; % title of the image as decription

댓글 수: 2

KSSV
KSSV 2017년 2월 6일
You can directly use without pos also...
idx = strcmpi(images(ix),image_names) ; % compare the image names
title(image_desc(idx)) ; % title of the image as decription
this directly works too.
Did you mean only use
image_names = namePic(2:end,1) ; % image names
image_desc = namePic(2:end,2) ; % image description
idx = strcmpi(images(ix),image_names) ; % compare the image names
title(image_desc(idx)) ; % title of the image as description

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

질문:

2017년 2월 5일

댓글:

2017년 2월 21일

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by