5.0

5.0 | 5 ratings Rate this file 13 downloads (last 30 days) File Size: 3.48 KB File ID: #4104

XLS2STRUCT

by Andreas

 

29 Oct 2003 (Updated 28 Jan 2005)

Code covered by BSD License  

Reads xls-file and converts table into a structure.

Download Now | Watch this File

File Information
Description

[S,E] = XLS2STRUCT(FILE) reads the Excel-file FILE and converts the columns
 into separate fields in the structure S. The first line of the file
 must contain unique headers for all of the columns, the rest of the file
 is data.

 Column names can contain spaces, these are converted to underscores in
 order to obtain proper variable names.

 S is the plane representation of the table. E is a second structure with
 an element-wise representation. I.e. notation S.Time(i) versus E(i).Time.

 XLS2STRUCT(FILE,SHEET) reads SHEET instead of the default sheet.

 Example:
     City Time Temp
    Dallas 12 98
    Tulsa 13 99
    Boise 14 97

 converts to
 S.City = {'Dallas','Tulsa','Boise'}';
 S.Time = [12 13 14]';
 S.Temp = [98 99 97]';

 E(1)
 ans =
    City: 'Dallas'
    Time: 12
    Temp: 98

MATLAB release MATLAB 7.0.1 (R14SP1)
Other requirements The new version requires Matlab 7. However an pre 7 version is included.
Zip File Content  
Other Files structrows.m,
xls2struct.m,
xls2structpre7.m
Tags for This File  
Everyone's Tags
Tags I've Applied
Add New Tags Please login to tag files.
Comments and Ratings (6)
21 Nov 2003 Sergio Lucero

very useful, works great

16 Mar 2004 Matt Swann

Fantastic - my quality of life has improved. Thanks.

06 Aug 2004 Thomas Dionysopoulos

XLNT, bravo!

18 Nov 2004 Matthew Hoffman

BRILLIANT! Should've thought of it myself. Gets rid of hundreds of lines of interpretive code.

17 Dec 2004 Mark Bower

Very helpful and easy to use. It would be nice to have the inverse function, 'struct2xls', too!

17 Aug 2007 Dmitry Savransky

Works exactly as advertised - great time saver. Would be nice to have equivalent functionality on *nix systems, but that is the fault of the built-in routines, not the author. Thanks!

Please login to add a comment or rating.
Updates
29 Nov 2004

The updated version converts headers like "column A" to "column_A".

24 Jan 2005

The function is greatly simplified by using the option in xlsread to read the raw data table. This also fixes some problems with mixed/numeric tables

24 Jan 2005

The function is greatly simplified by using the option in xlsread to read the raw data table. This also fixes some problems with mixed/numeric tables

24 Jan 2005

The function is greatly simplified by using the option in xlsread to read the raw data table. This also fixes some problems with mixed/numeric tables

28 Jan 2005

A major bug in the last update.

Tag Activity for this File
Tag Applied By Date/Time
data import Andreas 22 Oct 2008 07:09:08
data export Andreas 22 Oct 2008 07:09:08
file io excel structure Andreas 22 Oct 2008 07:09:08
data Andreas 22 Oct 2008 07:09:08
utilities Andreas 22 Oct 2008 07:09:08
import Andreas 22 Oct 2008 07:09:08
export Andreas 22 Oct 2008 07:09:08
 

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