Effacer les filtres
Effacer les filtres

How can I make figure background black and move stimulus to the right?

1 vue (au cours des 30 derniers jours)
Jinah Lee
Jinah Lee le 24 Mar 2017
Hello, I'm having trouble to generate psychophysics experiment. I'm trying to test stimulus detection when stimulus moves to the right of the fixation and width of movement are randomly distributed.. The background of figure should be black and fixation and stimulus should be white. However, somehow, my figure turned into white. So I couldn't see the stimulus. Could someone point out how can I turn my figure background into black and display stimulus randomly somewhere in the right side of the fixation? Here's my code. Thanks a lot!
temp = uint8(zeros(400,400,3)); %Create a dark stimulus matrix
temp1 = cell(10,1); %Create a cell that can hold 10 matrices
for ii = 22:41 %Filling temp1
temp(200,200,:) = 255; %Inserting a fixation point
p = (ii-1)*10;
temp(200,p,:) = 255; %Inserting test point randomly between 10 pixels to 100 pixels right of it from 210th to 400th column.
temp1{ii} = temp; %Putting the respective modified matrix in cell
end %Done doing that
h = figure %Creating a figure with a handle h
stimulusorder = randperm(200); %Creating a random order from 1 to 200.
%For the 200 trials. Allows to have a precisely equal number per condition.
stimulusorder = mod(stimulusorder,10); %Using the modulus function to
%create a range from 0 to 9. 20 each.
stimulusorder = stimulusorder + 1; %Now, the range is from 1 to 10, as
%desired.
preiScore = zeros(10,1); %Keeping score. How many stimuli were reported seen
for ii = 1:200 %200 trials, 20 per condition
image(temp1{stimulusorder(1,ii)}) %Image the respective matrix. As
%designated by stimulusorder
ii %Give observer feedback about which trial we are in. No other feedback.
pause; %Get the keypress
temp2 = get(h,'CurrentCharacter'); %Get the keypress. “y” for present,
%“n” for absent.
temp3 = strcmp('y', temp2); %Compare strings. If . (present), temp3 5 1,
%otherwise 0.
preiScore(stimulusorder(1,ii)) = preiScore(stimulusorder(1,ii)) + temp3; %Add up.
% In the respective score sheet.
end %End the presentation of trials, after 200 have lapsed.

Réponses (1)

Nagini Venkata Krishna Kumari Palem
It seems you wish to set the background color of the figure to black. Set the 'Color' property value to either 'black' or 'k' or [0 0 0]. In your case, you can use the figure handle 'h' as follows.
h.Color = 'k'
For more information refer to figure properties

Catégories

En savoir plus sur Psychology dans Help Center et File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by