Hi,
Have spent a few days introducing myself to both Matlab and PsychToolbox using the various guides and online tutorials as I need to build an experiment. Having cribbed and tweaked bits of the pbtutorials I have now manged to get three coloured squares evenly spaced at the top of the screen (code pasted below). So far so good. My next task is to have those squares move at an independently controllable speed from their position at the top of the screen to one at the bottom (move down the y, stay constant on the x). I’m (maybe foolishly) assuming that this is relatively simple to code but all the guides seem to be coding for something more complex. I was hoping the “Moving Line Demo” would help me out but whilst I can run the demo I can’t view the code (or don’t know how). Any pointers would be much appreciated, thank you.
sca;
close all;
clearvars;
PsychDefaultSetup(2);
screens = Screen(‘Screens’);
screenNumber = max(screens);
white = WhiteIndex(screenNumber);
black = BlackIndex(screenNumber);
[window, windowRect] = PsychImaging(‘OpenWindow’, screenNumber, white/2);
[screenXpixels, screenYpixels] = Screen(‘WindowSize’, window);
[xCenter, yCenter] = RectCenter(windowRect);
baseRect = [0 0 100 100];
squareXpos = [xCenter 0.25 xCenter xCenter 1.75];
squareYpos = [yCenter0.1 yCenter0.1 yCenter*0.1];
numSqaures = length(squareXpos);
allColors = [1 0 0 ; 0 1 0 ; 0 0 1 ]’;
allRects = nan(4, 3);
for i = 1:numSqaures
allRects(:, i) = CenterRectOnPointd(baseRect,…
squareXpos(i), squareYpos(i));
end
Screen(‘FillRect’, window, allColors, allRects);
Screen(‘Flip’, window);
KbStrokeWait;
sca;