Trouble with correct indexing and randomization

Hi guys!

I'm programming a task but I ran into serious trouble. I want to show pictures with 4 corresponding names (it's a task for testing face-name memory).

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. The problem is that I don't manage to show the randomized names; instead, they are shown in the order of the dictionary. How do I randomize them correctly??




To exemplify what I refer to I show you some Code snippet which hopefully help:

nameCues1 = {'Lisa','Anna', 'Sarah', 'Nina', 'resized_1.jpg' };
nameCues2 = {'Emma', 'Lena', 'Gabi', 'Steffi', 'resized_2.jpg' }

I have loaded them into a cell array:

 nameCuesAll = {nameCues1,nameCues2, nameCues3}

 I create a randomized sequence:

 randSeq3 = nameCuesAll(randperm(size(nameCuesAll,2)));
 %% Loop for Rating Phase
% Reads facial stimuli  
for i = 1:numel(nameCuesAll)
    pics3{i} = imread(randSeq3{i}{1,5});
    ind{i}=randperm(numel(randSeq3{i})); <---- does not work 

end 

Then I prompt in on the Screen via the function of Psychtoolbox. I just show the DrawFormattedText function here:

 for j = 1:4
  %%here I leave out some unnecessary functions of Psychtoolbox 
DrawFormattedText(window,ind{i}(j), 'center', 'center', white, [], [], [], [], [], rect);
     end



Thank you very much! 


PR

Thank you very much for your elaborating answer! I appreciate it that you also gave an example of how you would code it. It helped a lot.
In the meantime I was able to solve my issue, similiarly to your solution (but of course more confusing).
I unterstand that the code might hurt, - hopefully my skills progress so that my code isn't hurting any more ;). Yeah, multidimensional arrays are especially for beginners not easy to get.
no problem!

i should add that there are times when writing compact, vectorised code in MATLAB is really important. this mostly applies when doing operations on large amounts of data, where a change in code structure can make a huge difference in computation time...