Hamming weight for a list of integers in Matlab [duplicate]
问题 This question already has answers here : Calculating Hamming weight efficiently in matlab (9 answers) Closed 6 years ago . Quite a simple problem: I have a list of integers, e.g., a = [7 8] Now I want to have a seperate list, that contains the Hamming Weight (that is the number of 1 bits in the binary represenation) for each of the integers in the list. That means the result for the integer list above should look as follows: res = [3 1] Anyone an idea how I could do this quickly? 回答1: This is