How to merge numerical cell and char cell of binary values into 1 cell in matlab -


i have matlab cell of 7395x28 numerical values , have character cell of 7395x8 in there binary values. want binary values cell merged numerical value cell without change.

for example let numerical cell , binary cell b merged them this

c=[a,b]

this gives me error saying cannot merge character cell numerical values cell. please me how solve

the output should merged cell , last column of cell should consist of binary values. please help.

code

a1 = num2cell(randi(5,2,3)) %%// cell array of numerical values a2 = {'0' '1' '1'; '0' '1' '0' } %%// cell array of characters binary numbers out = num2cell(cell2mat(a1)*10+cell2mat(a2)-'0')  

output

a1 =       [4]    [3]    [5]     [2]    [4]    [5]   a2 =       '0'    '1'    '1'     '0'    '1'    '0'   out =       [40]    [31]    [51]     [20]    [41]    [50] 

edit 1:

code

a={1,2,3;     2,3,4;     4,5,6;     7,8,9;     0,9,9}  b={'0001'; '0011'; '0111' ;'1111' ;'0101'}   c = [a cellstr(cell2mat(b))] 

output

c =       [1]    [2]    [3]    '0001'     [2]    [3]    [4]    '0011'     [4]    [5]    [6]    '0111'     [7]    [8]    [9]    '1111'     [0]    [9]    [9]    '0101' 

edit 2:

code

a={1,2,3;     2,3,4;     4,5,6;     7,8,9;     0,9,9}  b = ['00000001';'00010001';'00000001';'10110001';'01010011']  c = [a cellstr(b)] 

output

c =       [1]    [2]    [3]    '00000001'     [2]    [3]    [4]    '00010001'     [4]    [5]    [6]    '00000001'     [7]    [8]    [9]    '10110001'     [0]    [9]    [9]    '01010011' 

Comments

Popular posts from this blog

apache - Remove .php and add trailing slash in url using htaccess not loading css -

javascript - jQuery show full size image on click -