MATLAB: How to add 1 into the array additionarraybinarymatrices I have an array M =[1 0 0] How can I add 1 into the array so the answer will be N=[1 0 1] If I add other 1, the answer will be O = [1 1 0] Best Answer Try this: binadd = @(a,b) dec2bin(bin2dec(a) + bin2dec(b)); % Create FunctionM = '100';N = binadd(M, num2str(1))O = binadd(N, num2str(1))producing: N = '101'O = '110'To create a numeric array, subtract '0': Onum = O - '0'Onum = 1 1 0 Related SolutionsMATLAB: How to permute binary numbers to a specific permutation https://de.mathworks.com/help/matlab/ref/circshift.htmlF=[0 6 2 5 4 3 6 1]'A = dec2bin(F)B = circshift(A,1,2)gives:F = 0 6 2 5 4 3 6 1A = 8×3 char array '000' '110' '010' '101' '100' '011' '110' '001'B = 8×3 char array '000' '011' '001' '110' '010' '101' '011' '100' MATLAB: Array of 1 and 0 to decimal B = bin2dec(char(A + '0'))B = 147 15 170 Related QuestionHow to convert A=[1 3 2] to B= [ 1 0 0;0 0 3;0 2 0]Hi,,is there anyone who could tell me,how to generate a 10 bit binary data with only ONE in the first position and rest is zero
Best Answer