Problems with Indexing of cell array
2 次查看(过去 30 天)
显示 更早的评论
Hi guys!
The problem I have is the following: I have a dictionary with names and with one picture. I create a randomized sequence for my pictures. Now I want to display (via Psychtoolbox) the respective Name Cues for the image, but in randomized order. Hopefully my code snippet does show you what I mean:
nameCues1 = {'Lisa','Anna', 'Sarah', 'Nina', 'resized_1.jpg' };
nameCues2 = {'Emma', 'Lena', 'Gabi', 'Steffi', 'resized_2.jpg' };
nameCues3 = {'Tanja', 'Luisa', 'Jana', 'Nicole', 'resized_3.jpg' };
nameCues4 = {'Clara', 'Tina', 'Katja', 'Susi', 'resized_4.jpg' };
I have loaded them into a cell array:
nameCuesAll = {nameCues1,nameCues2, nameCues3}
Now I create a randomized sequence:
randSeq3 = nameCuesAll(randperm(size(nameCuesAll,2)));
%%Loop for Rating Phase
% Reads facial stimuli for "Explicit Recognition Phase"
for i = 1:numel(nameCuesAll)
pics3{i} = imread(randSeq3{i}{1,5});
ind{i}=randperm(numel(randSeq3{i}));
ind{i}=randSeq3{i}{ind}; %this doesn't work yet!
end
Then I prompt in on the Screen via the function of Psychtoolbox:
for j = 1:4
%%here I leave out some unnecessary functions of Psychtoolbox
DrawFormattedText(window,ind{i}(j), 'center', 'center', white, [], [], [], [], [], rect);
end
I put in some hard hours, but didn't come close to a sufficient solution. I would be very glad if someone could help me out here.
Thanks so much!
5 个评论
Ameer Hamza
2018-5-27
编辑:Ameer Hamza
2018-5-27
I am not sure, but it appears that you want to do something like this
ind{i}=randSeq3{i}(randperm(numel(randSeq3{i})));
You might want to go through indexing concepts in MATLAB
回答(0 个)
另请参阅
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!