MATLAB: How to convert a single row matrix into a number (double)

helpquestion

how to convert a single row matrix into a number (double) for exemple: [1 2 3 4 5] into 12345

Best Answer

a=[1 2 3 4 5];
b=str2double(sprintf('%d',round(a)));
Another method would be to use positional information:
a=[1 2 3 4 5];
b=sum(a.*10.^((length(a)-1):-1:0));
This second method will often work better, but if values larger than 9 are present in a, this will not return the result you might mean.