I am trying to design a matlab program that can continuously update a horizontal bar graph as the user presses a certain key on the Cedrus box (RB-730).
I was able to get matlab to communicate with the response box using the code found in one of the earlier posts on using matlab with the response box. I was able to get a graph that updated too, but the graph does not update quickly enough when I press the keys at a fast rate.
My question:
Is it possible for the subject to continuously press and hold a key and can matlab keep updating the size of the bar as the key is pressed at a certain rate.
I have posted the code I’m currently using below. cedrusxid refers to the function from one of the previous posts on accessing the Response Box. Any suggestions are greatly appreciated.
Thanks,
Anil.
function [ output_args ] = test
%TEST Summary of this function goes here
% Detailed explanation goes here
maxscale = 55;
tension = 1;
barh([tension maxscale]);
drawnow;
x=0;
while x<100
y = cedrusxid;
if y == 80
tension = tension + 1;
end
if y == 112
tension = tension - 1;
end
if y == 48
x = 100;
end
barh([tension maxscale]);
drawnow;
x=x+1;
I was able to make some progress but still having trouble on keeping the horizontal bar growing as the subject holds down a key. I’ve posted the modified code below. Basically, instead of calling cedrusxid again and again, I only call the fopen and fclose once. This makes for a faster response to the bar growth. Any help is greatly appreciated.
Thanks,
Anil.
function [ output_args ] = test
%TEST Summary of this function goes here
% Detailed explanation goes here
After trying many different things, I think the best solution to get Matlab to communicate with the cedrus boxes is to use Cogent (a Matlab toolbox, see link below)
It allows any matlab script to effortlessly access responses from I think most cedrus boxes. However, I don’t think cogent is very adept at reading bytes send in the xid protocol, so I would recommend that users set their boxes to RB series mode (baud rate shouldn’t matter).
I’m almost done with the code I wanted to use (that can continuously draw a graph as the user holds down a button) with the help of cogent and will post it here shortly.