MATLAB: Is this works in Matlab?! K = (N==INFECTED_A1) + (E==INFECTED_A1) + (S==INFECTED_A1) while INFECTED_A1=1. How to get K=3?!

Hi all I have 8 variables are named N,E,S, et.c. And an INFECTED_A2 = 1 variable; N,E,S … get their values from some other part of code and the user does not access them to set values, I want to sum the values of these variables which they are equal to INFECTED_A1. I mean if N== INFECTED_A1 then I want to plus a counter(K) and if E==INFECTED_A1 then the counter(K) increases 1 more. I know that I can do this by if statements but I want to know that is the following code gives equal results in Matlab or not?!
INFECTED_A2=1
%for example consider N=INFECTED_A2; E=INFECTED_A2; S=INFECTED_A2;
K =(N==INFECTED_A2 + E==INFECTED_A2 + S==INFECTED_A2);
I should get ----> K=3
I know if I use the following code
K = (N==INFECTED_A1 || E==INFECTED_A1 || S==INFECTED_A1);
I will get ---> K=1
I want to know is there any syntax that do this in Matlab without using many if statements?!
Thanks you all.

Best Answer

Have to use paren's to get proper precedence--
K =(N==INFECTED_A2) + (E==INFECTED_A2) + (S==INFECTED_A2);