MATLAB: How do i combine data of cells or strings with double matrix

cell arraycombining string and double arrayexcelstring

i have column names that are in a cell array and i have a double matrix. I need to combine them together and then save them to an excel file. I get the information from a uitable.
need a way to combine data of cells or strings with double matrix
doubledata=get(handles.uitable,'data');
colnames=get(handles.uitable,'Columnname');
colstring=cell(colnames);
%combineddata=???
filename=uiputfile('*.xlsx','Save File As');
xlswrite(filename,combineddata);

Best Answer

I think you mean
colstring = cellstr(colnames);
The column names would usually already be in cellstr format, but it doesn't hurt to specifically convert them just in case they were not. Likewise sometimes the Data from a uitable is a cell and sometimes it is an array, so
if ~iscell(doubledata)
doubledata = num2cell(doubledata);
end
After that,
combineddata = [colstring; doubledata];