how to concatenate multiple columns of an array to single column in matlab?

I used dectohex function to convert a set of bytes to hexadecimal.For example A=[255 216].h=dec2hex(A) is giving me a 2*2 matrix instead of 2*1.First F is in one column and 2nd F in another column.I wanted the FF to be in single cell.
h=
FF
D8

Answers (2)

To convert to a cell array of strings, e.g.,
mat2cell(h,ones(size(h,1),1),2)
This encapsulates the rows h(row,:) in individual cells. Is that what you want?
If you have the strsplit function:
A=[255 216];
h = strsplit(sprintf('%2X %2X', A), ' ')'
h =
'FF'
'D8'

Categories

Asked:

on 26 May 2015

Answered:

on 26 May 2015

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!