Merging two arrays of two different types
6 views (last 30 days)
Jorg Woehl on 6 Mar 2021
You are combining double values (from a) with character values (from b), which yields a character array according to MATLAB's class conversion rules. The doubles 1, 2, and 3 are converted to their Unicode character equivalents, which are control characters and only result in empty characters/whitespace when displayed.
If you want your resulting vector c to contain the numbers from a instead, first convert the doubles to characters using num2str. Using it on the array a will lead to additional whitespace, which you may or may not want... but you can strip that out using the replace function:
c = [num2str(a) b]
'1 2 3aa'
c = replace([num2str(a) b], ' ', '')