Borrar filtros
Borrar filtros

how do you program matlab to select a number that wasn't presented in the stimuli? 50/50 between presented and not presented numbers for the Sternberg Task

3 visualizaciones (últimos 30 días)
rng('Shuffle'), ([a b c d e]) a = randperm(10, 5)-1 %length(a) for k=1:length(a) clf;text(0.5,0.5, num2str(a(k)),'FontSize',75);axis off; pause(1) clf; end for x1 = randsample(a,1), pause(2) clf;text(0.5,0.5, num2str(x1),'Fontsize',75);axis off end
So far the code i am using only selects a number that was presented but not a number that wasn't. Can anyone please help me solve this problem?

Respuestas (1)

Amy
Amy el 12 de Dic. de 2017
Hi Michael,
If you look at the documentation for the randsample function, you will see the following:
" y = randsample(population,k) returns a vector of k values sampled uniformly at random, without replacement, from the values in the vector population. "
So this means when you write:
x1 = randsample(a,1)
'x1' will only ever be assigned a value from a. If you want 'x1' to be any value from 1 to 10, you would just replace 'a' with 10:
x1 = randsample(10,1)

Categorías

Más información sobre Mathematics and Optimization 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!

Translated by