Code covered by the BSD License  

Highlights from
XLS2STRUCT

5.0

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

XLS2STRUCT

by Andreas

 

29 Oct 2003 (Updated 28 Jan 2005)

Reads xls-file and converts table into a structure.

| 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.
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
export Andreas 22 Oct 2008 07:09:08
import Andreas 22 Oct 2008 07:09:08
data Phattharaphon Wiengnak 14 Dec 2011 12:09:28
data export Phattharaphon Wiengnak 14 Dec 2011 12:09:31
utilities Phattharaphon Wiengnak 14 Dec 2011 12:09:35

Contact us at files@mathworks.com