open multiple pictures from a list with for loops

조회 수: 1 (최근 30일)
Tim Dreßler
Tim Dreßler 2023년 1월 4일
편집: Voss 2023년 1월 4일
Hello,
I have the following problem:
I have a huge pool of pictures of which every participant in an experiment saw a portion of. Every participant has it's indiviual StimulusList in which all pictures are listed which they saw.
My goal is to enter the StimulusList of one participant and to see all the pictures he/her saw. I don't care if they open in separate windows or if I click through them (like in a gallery) (altough I'd prefer the latter version).
I have coded the following: The code works (no errors) but it only opens one picture.
All files (StimulusLists and Pics) are stored in the same WD.
clc
clear
load VP_001_StimulusList.mat; %enter StimulusList here
StimulusList = struct2table(StimulusList);
StimulusList.num = num2str(StimulusList.num, '%03d'); %add leading zeros (in the StimulusList there are no leading
%zeros but in the file names of the pics there are, hence I added them)
StimulusList.pic = strcat(StimulusList.type, '_', StimulusList.num); %the filenames of the pics are always set up as
%following negative[or]neutral_XXX, the negative[or]neutral condition and
%the number are stored in different collumns of the StimulusList, hence I
%used strcat()
for i = height(StimulusList)
file = StimulusList{i,4};
file_cat = strcat(file, '.jpg');
file_cat = string(file_cat);
img = imread(file_cat);
figure, imshow(img);
end
%the loop works but it only opens one window and one picture
Thank you for your help!
and happy new year :)

채택된 답변

Voss
Voss 2023년 1월 4일
for i = height(StimulusList)
should be:
for i = 1:height(StimulusList)
  댓글 수: 6
Tim Dreßler
Tim Dreßler 2023년 1월 4일
The pause option is already nice but I'll try to build a little GUI - Thank you so much - made my night
Voss
Voss 2023년 1월 4일
편집: Voss 2023년 1월 4일
You're welcome!

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

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Migrate GUIDE Apps에 대해 자세히 알아보기

제품


릴리스

R2022b

Community Treasure Hunt

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

Start Hunting!

Translated by