MATLAB: Distance between two matrices hamming distance I have to compute the hamming distance between two matrices. a=[240*7]; b=[240*7]; dist=hamming (a,b); but this code shows error. what i do? I need the solution. Best Answer hamming is not for hamming distance I guess. What is the type of input you want to compute the hamming distance.Hamming distance is usually calculated between character array or binary array. For binary array it is very simple and straight forward.For binary array sum of absolute difference can give you hamming distance.For example.a = [1 0 0 1];b = [1 1 1 1];h_d = sum(abs(a-b)); Related SolutionsMATLAB: Calculating hamming distance and return the array correspondingly to minimum value between the given possibilities arr=[1 0 0 1]tuple = [ 1 0 0 0 ; 1 1 1 1 ; 0 0 0 0 ] % cell2mat({ 1 0 0 0 ; 1 1 1 1 ; 0 0 0 0})n = sum(xor(tuple,arr),2);[minn, r]=min(n);best=tuple(n==minn,:) MATLAB: Hamming distance between two binary matrices D = pdist2(X,Y,'hamming') Related QuestionHamming distance in one matrixHow to calculate the shortest distance between points and a line
Best Answer