MATLAB: Comparing 2 column vectors

matlab code comapre columns vectors fprintf

Lets say I have 2 vectors: a = [0,0,1] b = [0,1,0]
ComparingĀ a and b, there is a a difference in 2 digits (column 2 and column 3). Therefor error rate is 2/3.
Can you help me set up a code that compares each column in vector a and b and that prints an error. Perhaps, use a for/if loop?
Thank you

Best Answer

a = [0,0,1]
b = [0,1,0]
out=mean(a~=b)