Dear Community,
I am running my experiment using Psychtoolbox. Unfortunately, I cannot share the whole script here, but generally it's a centre-out reaching task where my participants use a joystick to reach targets. The joystick trajectory is being tracked with high temporal resolution and saved.
The tasks is presented using Psychtoolbox-3 (3.0.19) running on the MATLAB platform (2021b) in ubuntu (22.04).
The script works somewhat unstable. In 50 percent of cases it runs smoothly without any issues. In the other 50 percent it crushes with the following error message:
Identifier: MATLAB:badsubscript (line 643)
Error: Index in position 1 exceeds array bounds. Index must not exceed 552.
Error in function TextSize: Invalid Window (or Texture) Index provided: It doesn't correspond to an open window or texture.
Did you close it accidentally via Screen('Close') or Screen('CloseAll') ?
oldTextSize=Screen('TextSize', windowPtr [,textSize]);
Error in C_cued_cursor_rotation_joystick_noCentre (line 727)
Screen('TextSize',wPtr, 40);
Here's a few lines of my script with line 643 highlighted:
motion(:,9) = [NaN; ((velo/pix_per_mm)/1000)];
trialDat{trial} = motion;
reachDat{trial} = motion(move_loc:endLoc,:);
reachDat{trial}(:,10) = trenddecomp(reachDat{trial}(:,9));
[maxVelo, maxLoc] = max(reachDat{trial}(:, 10));
I'm not a great expert in Matlab unfortunetely. What bugs me is that the script crushes at random time points. Sometimes after 50 trials, sometimes after 450+. And there seems to be nothing different im terms of participant's performance compared to other trials.
Do you have any ideas what can cause this issue?
And why it doesn't crush from the very first trial?