I have a vector a = [1 2 3 4 5] how would I make it so b = '12345'?
I have tried b = num2str(a) but it outputs 1 2 3 4 5.
You can specify the format in num2str, much as you would in C's function sprintf:
b = num2str(a,'%i');
Or use sprintf:
b = sprintf('%i',a);
If a contains only single-digit numbers, you can also convert to char directly:
b = char(a+'0');
'12345' was a string, not a number (otherwise use Shai's answer less the num2str part). So you want to assign a string to the first element of a variable c? If c has to store other strings of possibly different lengths, c should be a cell array; and you'd just do c{1} = bYou need to convert yor vector to a single number first (assuming all elements are in range 0..9):
a = 1:5;
num = ( 10.^((numel(a)-1):-1:0) ) * a'; %'
b = num2str( num )
You can try this code here.