how do i combine data of cells or strings with double matrix
19 views (last 30 days)
Show older comments
Jonathan Wamsley
on 20 Jul 2015
Commented: Jonathan Wamsley
on 20 Jul 2015
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);
0 Comments
Accepted Answer
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];
More Answers (0)
See Also
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!