Bitwise commands such as Bitor with many inputs?

Viewed 703

Matlab takes only two inputs with bitwise commands such as bitor. bitor(1,2) returns 3 and bitor(1,2,4) does not return 7 but:

ASSUMEDTYPE must be an integer type name.

Currently, I create for-loops to basically create a bitwise command to take as many inputs as needed. I feel the for-loops for this kind of thing is reinvention of the wheel.

Is there some easy way of creating the bitwise operations with many inputs?

Currently an example with some random numbers, must return 127

indices=[1,23,45,7,89,100];
indicesOR=0;
for term=1:length(indices)
    indicesOR=bitor(indicesOR,indices(term));
end
1 Answers
Related