num_digits = 3;
bit_divisor = 2.^(0:num_digits-1);
bit = zeros(2^num_digits,num_digits);
for combination = 0 : 2^num_digits - 1,
for nd = 1:num_digits,
% just bit shift to right and mask the right-most bit
bit(combination+1,num_digits-nd+1) = rem(floor(combination/bit_divisor(nd)), 2)
end
end % combination loop
Showing posts with label matlab. Show all posts
Showing posts with label matlab. Show all posts
How to Create Binary Table in MATLAB Elegantly
Hide number on axis in a plot on MATLAB
set(gca,’XThick’,[])
set(gca,’YThick’,[])
set(gca,’ZThick’,[])
set(gca,’YThick’,[])
set(gca,’ZThick’,[])
How to Sort a Vector With the Same Order As Other Vector in Matlab
Example :
A = [5 3 4 1 2]; B = [-6 -8 -7 -10 -5];Answer :
C = sortrows([A.' B.']);or
[A, idx] = sort(A); B = B(idx);
Subscribe to:
Posts (Atom)