mardi 6 janvier 2015

Matlab Correct/Incorrect keyboard response using if statement

This is for a psychology experiment using MatLab. I'm trying to write an if statement which checks the participant's keyboard response and then creates a new variable which is correct or incorrect, which can then be printed to an outputfile. Below is a simplified version of my real problem . The 2 variables are CatMLoc and responsenumber.


CatMLoc is a string either 'Left' or 'Right' and is randomly determined on every trial.


responsenumber is the keyboard input from the participant and can be either 'a' or 'l' (lower case L).



CatMLoc='Left';
responsenumber='a';

if CatMLoc=='Left' & responsenumber=='a'
CatAnswer='Correct';
else CatAnswer='Incorrect';
end;
disp(CatAnswer)

Aucun commentaire:

Enregistrer un commentaire