Save Structure to a new excel sheet
2 views (last 30 days)
Show older comments
How do I save a structure containing one numeric field and one string field in a particular sheet in excel?
0 Comments
Answers (1)
Image Analyst
on 15 Nov 2021
You can store the values in a cell array and then use xlswrite(). Untested code:
ca = cell(2, 2);
ca{1, 1} = 'My Number';
ca{1, 2} = str.NumericField; % Put the number into row 1, column 2.
ca{2, 2} = {str.StringField}; % Put the string's row header into row 2, column 1.
ca{2, 2} = str.stringField; % Put the string into row 2, column2.
xlswrite(xlFullFileName, ca, 'Sheet 1', 'A1')
P.S. If
ca{2, 2} = {str.StringField};
doesn't work, try
ca{2, 2} = str.StringField;
but sometimes if you don't put the string into a cell, it just puts one letter of your string in different cells in Excel.
0 Comments
See Also
Categories
Find more on Spreadsheets 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!