Hi community, I wrote a program in Matlab where I asked the user to enter a value between 0 and 100 followed by «Enter» and save the answer. I use KbQueue functions and the script works fine on my Mac, but somehow, it doesn’t work when I try to run in on a Windows computer.
Here’s the code for the concerned part:
% User's response. Doesn't show on the screen, but answer's saved respArray = ""; KbQueueCreate; % initialize the Queue EXIT_SIGNAL = 0; KbQueueStart; while ~EXIT_SIGNAL [pressed, firstPress, firstRelease, lastPress, lastRelease]=KbQueueCheck; if pressed if ~(strcmp(KbName(find(firstPress)), 'Return')) respArray = respArray + regexp(KbName(find(firstPress)),'[0-9]','match'); elseif any(strcmp(KbName(find(firstPress)), 'Return')) EXIT_SIGNAL = 1; end end end KbQueueStop; KbQueueRelease; user_temp_response = respArray;
The script seems to be stuck on this line of code:
respArray = respArray + regexp(KbName(find(firstPress)),'[0-9]','match');
I receive the error message «Error using regexp. The ‘STRING’ input must be either a char row vector, a cell array of char row vector, or a string array.»
Thank you for your help,