RSVP : REPLACE LETTERS WITH DIGITS
2 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
Migmar Tsering
el 22 de Oct. de 2019
Comentada: Migmar Tsering
el 23 de Oct. de 2019
% CONDITION 1 = RSVP OF 13-21 LETTERS RANDOMLY WITHOUT REPLACEMENT
% CONDITION 2 = 2 OF THE LETTERS WERE REPLACED WITH DIGITS, RANDOMLY DRAWN
% CONDITION 3 = T2 IS PRESENTED 3 TO 6 TEMPORAL POSITIONS FROM THE END
% CONDITION 4 = T1 AND T2 VARIED FROM 1:5 ITEMS
I am trying to run psychtoolbox for my RSVP experiment. can someone please help me to program (replace) letter stream with T2 and T1 as required in condition 3 and condition 4.
s = ['A' 'B' 'C' 'D' 'E' 'F' 'G' 'H' 'J' 'K' 'L' 'M' 'N' 'P' 'R' 'T' 'U' 'V' 'W' 'X' 'Y' 'Z'];
str=datasample(s,1,'Replace', false);
nletters = [13:21];
ntrial = datasample(nletters,1);
T1 = randi([2,9], black);
T2 = randi([2,9], black);
l2 = datasample(nletter);
for index = 1:ntrial
str=datasample(s,1,'Replace', false)
T1 = strrep(s,
T2 = strrep(s,
end
2 comentarios
Guillaume
el 22 de Oct. de 2019
Your question is not clear. What's T1, what's T2, what does "T1 AND T2 VARIED FROM 1:5 ITEMS" mean? Please provide an example of what you want.
The code you've written doesn't make much sense, you're using some functions incorrectly and you're using undefined variables such as black and nletter.
Note that:
s = ['A' 'B' 'C' 'D' 'E' 'F' 'G' 'H' 'J' 'K' 'L' 'M' 'N' 'P' 'R' 'T' 'U' 'V' 'W' 'X' 'Y' 'Z'];
is exactly the same as the much simpler:
s = 'ABCDEFGHIJKLMNOPQRSTUVXYZ';
and could be generated with the even simpler:
s = 'A':'Z';
Respuesta aceptada
Guillaume
el 22 de Oct. de 2019
s = 'A':'Z';
%condition 1
numletters = randi([13, 21]); %number of letters to select is a random number from 13 to 21 letters
rsvp = s(randperm(numel(s), radn)); %draw that number of letters randomly without replacements
%condition 2
digits = '0':'9';
replaceidx = randperm(numel(rsvp), 2); %select 2 different indices
replacement = digits(randi(numel(digits), 2)); %and two digits. If the two digits MUST be different use randperm instead of randi
rsvp(replaceidx) = replacement; %replace the letters at the two random indices by the random digits
As per my comment to your question, I have no idea what the other 2 conditions mean.
3 comentarios
Guillaume
el 23 de Oct. de 2019
allletters = 'A':'Z'; %whole alphabet
letterset = setdiff(allletters, 'IOQS'); %remove IOQS from set
digits = '2':'9';
%step 1. Draw 13 to 21 letters without replacement
numletters = randi([13, 21]); %number of letters to select is a random number from 13 to 21 letters
rsvp = letterset(randperm(numel(letterset), numletters)); %draw that number of letters randomly without replacements
%step 2. Select two different digits
replacements = digits(randperm(numel(digits), 2));
%step 3. Put one digit, 3 to 6 indices from the end, the other one 1 to 5 indices before that
positions = randi(numel(rsvp) - [6, 3]) - [randi(5), 0];
rsvp(positions) = replacements %do the replacement
Más respuestas (0)
Ver también
Categorías
Más información sobre Characters and Strings en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!