4.0

4.0 | 1 rating Rate this file 39 downloads (last 30 days) File Size: 2.34 KB File ID: #22510

struc2xls

by Jeff Evans

 

22 Dec 2008

Code covered by BSD License  

Writes a data structure in MATLAB to an excel file.

Download Now | Watch this File

File Information
Description

Modified from Francisco de Castro's code, struc2xls lets you save data structures containing a mix of numeric and non-numeric data to an Excel file. This version runs faster than the original and has several extra output options.

STRUC2XLS (FILE,S) writes the data structure S to an Excel workbook named FILE in the current directory. Data fields can be numeric, non-numeric, or mixed. Output can be oriented vertically (field names in first column, data in rows) or horizontally (field names in first row, data in columns). I'm sure there's room for improvement here. Let me know...

EXAMPLES:
Create a sample structure 's' with two fields:
     s=struct('Name',{'Jon','Jonathan','Johnny'},'Score',[85,100,75]);

Basic output to file 'demo.xls' in current directory:
     struc2xls('demo',s)

Output beginning in cell D4 of Excel file:
     struc2xls('demo',s,'Col','D','Row',4)

Output to specified worksheet 'Students':
     struc2xls('demo',s,'Sheet','Students')

Output horizontal data (header row, data in columns):
     struc2xls('demo',s,'Orientation','H')

Output to alternate directory
     struc2xls('C:\Users\Johnny\Desktop\demo',s)

Acknowledgements

The author wishes to acknowledge the following in the creation of this submission:
struc2xls

MATLAB release MATLAB 7.6 (R2008a)
Tags for This File  
Everyone's Tags
Tags I've Applied
Add New Tags Please login to tag files.
Comments and Ratings (1)
07 Jan 2009 Ofek Shilon

Nice effort - but i'd given it 5 if it only handled nested structs.

Please login to add a comment or rating.
Tag Activity for this File
Tag Applied By Date/Time
data export Jeff Evans 23 Dec 2008 14:09:33
data import Jeff Evans 23 Dec 2008 14:09:33
structure Jeff Evans 23 Dec 2008 14:09:33
xls2struct Jeff Evans 23 Dec 2008 14:09:33
excel Jeff Evans 23 Dec 2008 14:09:33
data export Iris Hsu 11 Jun 2009 18:34:02
 

MATLAB Central Terms of Use

NOTICE: Any content you submit to MATLAB Central, including personal information, is not subject to the protections which may be afforded information collected under other sections of The MathWorks, Inc. Web site. You are entirely responsible for all content that you upload, post, e-mail, transmit or otherwise make available via MATLAB Central. The MathWorks does not control the content posted by visitors to MATLAB Central and, does not guarantee the accuracy, integrity, or quality of such content. Under no circumstances will The MathWorks be liable in any way for any content not authored by The MathWorks, or any loss or damage of any kind incurred as a result of the use of any content posted, e-mailed, transmitted or otherwise made available via MATLAB Central. Read the complete Terms prior to use.

Contact us at files@mathworks.com