how do i combine data of cells or strings with double matrix

19 views (last 30 days)
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);

Accepted Answer

Walter Roberson
Walter Roberson on 20 Jul 2015
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];
  1 Comment
Jonathan Wamsley
Jonathan Wamsley on 20 Jul 2015
Thank you soooo much again! You have greatly help me complete my gui so i can run a project much faster!

Sign in to comment.

More Answers (0)

Categories

Find more on Cell Arrays in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!