# Is it possible to check logic on more than two things at the same time?

5 visualizzazioni (ultimi 30 giorni)
Shannon Nyhus il 11 Dic 2019
Commentato: Walter Roberson il 11 Dic 2019
I'm programming a simple stroop task (very simple- I'm not very good at this). I've randomized the colors and the words to be presented and I have it set up so it will check to see if the color matches the word to save the reaction time as either congruent or incongruent.
I also want to record the correct and incorrect responses, but in order to do that, I'd need to check to see if the color matches the word AND the user's input. Is there a way to do that?
This is the code I have to check to see if the trials are congruent, but I'd also need to check to see if the user's input is "r".
if strcmp(excolortext,'RED')&excolor==[1 0 0]
excolor text is the word itself and excolor is the randomized color.
I'm sorry this is probably a pretty basic question. I'd appreciate any help you can give me.
##### 0 CommentiMostra -2 commenti meno recentiNascondi -2 commenti meno recenti

Accedi per commentare.

### Risposte (1)

Nicolas B. il 11 Dic 2019
Oh, pay attention what you are using for symbols. Just a friendly reminder:
&& -> and condition, work only with scalars
& -> and operator. work with logical vectors/matrices...
A longer explanation is available here.
In your case, you want to use the and condition && and if you compare vectors, you have 2 options:
% option 1: (not my favorite)
if all(myVec == [1 0 0])
end
% option 2:
if isequal(myVec, [1 0 0])
end
Than, you can easily add as many conditions as you want.
##### 1 CommentoMostra -1 commenti meno recentiNascondi -1 commenti meno recenti
Walter Roberson il 11 Dic 2019
if strcmp(excolortext,'RED') && all(excolor==[1 0 0])

Accedi per commentare.

### Categorie

Scopri di più su Modeling in Help Center e File Exchange

### Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by