I try to code an experiment. I have a Matrix with 4 Rows, where 1 row contains numbers from 1:20 which should be matched with a char Array {'B'…..'Z'} without vowels. I have several Conditions in FOR Loop for every Row:
trial = 1;for trial = 1:20 Trial(trial).Setsize = TrialMatrix(trial,1); Trial(trial).UpdatingSteps = TrialMatrix(trial,2); Trial(trial).Match = TrialMatrix(trial,3); Trial(trial).ProbeStim = TrialMatrix(trial,4); if Trial(trial).Match == 0 Stims = Stims(Stims ~= Trial(trial).ProbeStim); Trial(trial).EncodingStims = randsample(Stims,Trial(trial).Setsize+Trial(trial).UpdatingSteps); clear Stims elseif Trial(trial).Match == 1 && Trial(trial).UpdatingSteps == 0 cmpr0 = 0 while cmpr0 == 0 Trial(trial).EncodingStims = randsample(Stims,Trial(trial).Setsize+Trial(trial).UpdatingSteps) cmpr0 = ismember(Trial(trial).ProbeStim,Trial(trial).EncodingStims) end elseif Trial(trial).Match == 1 && Trial(trial).UpdatingSteps == 1 cmpr1 =0; cmpr2 =1; while cmpr1==0 && cmpr2==1 Trial(trial).EncodingStims = randsample(Stims,Trial(trial).Setsize+Trial(trial).UpdatingSteps) cmpr1 = ismember(Trial(trial).ProbeStim,Trial(trial).EncodingStims) cmpr2 = strncmp(Trial(trial).ProbeStim,Trial(trial).EncodingStims,1) end elseif Trial(trial).Match == 1 && Trial(trial).UpdatingSteps == 2 cmpr2 =0; cmpr3 =1; while cmpr2 == 0 && cmpr3 == 1 Trial(trial).EncodingStims = randsample(Stims,Trial(trial).Setsize+Trial(trial).UpdatingSteps) cmpr2 = strcmp(Trial(trial).ProbeStim,Trial(trial).EncodingStims); cmpr3 = strncmp(Trial(trial).ProbeStim,Trial(trial).EncodingStims,2) end endend
Especially the while loops are not working properly, the Conditions are violated. I want to compare, whether a letter is
- a.) Part of a Set of Letters
- b.) On which position of this Set (should not be on the first and the second position in some cases).
I tried this with strncmp and ismember, but I think this functions don't return a single true or false for my "Probe" but a vector, so that the loops quit incorrectly.
The Condtions for "NoMatch" and "Match" with no Updating are working fine, if I don't "convert" the sampled stimuli to chars like
% bla =(1:20);
% Stims = expinfo.letters(bla);
% Trial(trial).ProbeStim = expinfo.letters(Trial(trial).ProbeStim)
My question: are there functions for single value comparisons of chars (didn't found some) and how can I handle this char / numbers problem? Maybe you habe ideas, I'm kinda desperate.
greetings
Jan
Best Answer