- **Matlab Support**
(*http://community.cedrus.com/forumdisplay.php?f=15*)

- - **RB-730 with matlab**
(*http://community.cedrus.com/showthread.php?t=463*)

RB-730 with matlabHello All,
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; end |

Some ProgressHi Folks,
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 maxscale = 120; tension = 1; barh([tension maxscale]); drawnow; y = 0; s1 = serial('COM3', 'BaudRate', 115200,'DataBits', 8, 'StopBits', 1, 'FlowControl', 'none', 'Parity', 'none', 'Terminator', 'CR', 'Timeout', 400, 'InputBufferSize', 16000); fopen(s1); while y~=48 response = fread(s1,6); button = (response(2)); y = button; if y == 80 tension = tension + 5; end if y == 112 tension = tension - 5; end barh([tension maxscale]); drawnow; end fclose(s1); end |

Hello again Folks,
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) http://www.vislab.ucl.ac.uk/Cogent/ 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. Anil. |

1 Attachment(s)
Here is the file.
You'll need cogent to run it. |

All times are GMT -7. The time now is 12:26 PM. |

© Copyright Cedrus Corporation, 1991-2014.