@@ -95,6 +95,26 @@ Furthermore, two very useful functions are:
• [save2File](https://gitlab.ruhr-uni-bochum.de/ikn/OTBR/-/blob/master/Tools/save2File.m)(11.3.) to save all your workspace variables in a MATLAB file and
• [errorSave](https://gitlab.ruhr-uni-bochum.de/ikn/OTBR/-/blob/master/Tools/errorSave.m)(11.1.) that, in case of an error, still saves all variables and returns an error warning (needs to be called in a try-catch statement).
## Simple example
One simple example of a code that you can directly copy into your myExperiment.m file to try out simple functions of the toolbox (after adjusting myHardwareSetup and myParadigmSetup). Before trying out this example make sure that MATLAB’s working directory is correctly set to your experimental folder. It displays a text on the screen, waits for one second and closes the window and toolbox again.
The second advanced example will display a text and the toolbox will wait for 10 seconds or until the proper response (pressing key ’1’) has been made using the [keyBuffer](https://gitlab.ruhr-uni-bochum.de/ikn/OTBR/-/blob/master/IO/keyBuffer.m) function. After that depending on if a response has been made one of two text will be displayed followed by a one second waiting period. This is implemented by using a simple if statement and the output from [keyBuffer](https://gitlab.ruhr-uni-bochum.de/ikn/OTBR/-/blob/master/IO/keyBuffer.m)(see section 9.2. for clarification). Then the window and toolbox will be closed. Make sure to only press key ‘1’ when you are enabled to (during the ten second period when [keyBuffer](https://gitlab.ruhr-uni-bochum.de/ikn/OTBR/-/blob/master/IO/keyBuffer.m) is running).
This example makes use of the function keyBuffer, which is used for animal experiments mostly. Because you have no hardware like response keys or IO devices installed you can use the keyboard to test your experiments. The keyboard as response device is defined in myHardwareSetup.m in section 2 by default. If you would like to use an IO hardware device that is supported by our toolbox all you have to do is change the setting in section 2 and make sure the response keys is connected to pin 1 (or input 1).
The third example shows a similar experiment using the function getAnswer, which is mostly used in human experiments. In this example the program asks the user to press a key and presents the pressed key on the screen.
All examples use two computer monitors. If you want to run it on only one monitor, you have to delete the ‘(2)’ behind [initWindow](https://gitlab.ruhr-uni-bochum.de/ikn/OTBR/-/blob/master/Screen/initWindow.m). We recommend using two computer screens if possible. This allows to program in MATLAB or Octave on one screen and see the results on the second screen.
Depending on your device initWindow and [closeWindow](https://gitlab.ruhr-uni-bochum.de/ikn/OTBR/-/blob/master/Screen/closeWindow.m) may need some time to run. This means in an actual experiment when exact timing matters call the window initialization before the actual start of the experiment.