MATLAB: 2 dice simulation. Code for when both dice = 6

columndicerandivectors

*My first question wasn't clear.
I want to know how many double 6's there are basically.
For example,
a 6 2 6 2 6 1
b 6 4 5 6 6 3
I want something that would return the asnwer 2, indicating 2 double 6's, at positions 1 and 5.
Thanks*
Why won't this code tell me when a and b both equal 6?? I mean I know why, I just don't know what the right code is or how to correct it.
a=randi([1 6],n,1); disp('a='); disp(a);
b=randi([1 6],n,1); disp('b='); disp(b);
c=(a==6);d=(b==6); disp('c'); disp(c); disp('d'); disp(d);
e=(c==1);f=(d==1); disp('e=f'); disp(e==f);
The output I get is all of the times that (a==6)==(b==6) which I don't want.
NB: I've got an input code for n, don't worry.
Basically I need code that tells me the number of times both dice, a and b equal 6 at the same time/roll.
Thanks for any help.

Best Answer

sum((a==6)&(b==6))
Looks like the same question as this newsgroup thread: