Be the first to rate this file! 38 downloads (last 30 days) File Size: 2.16 KB File ID: #19707

xls2var

by Ashish Uthama

 

24 Apr 2008 (Updated 29 Dec 2008)

Code covered by BSD License  

Read Excel file and convert content to variables

Download Now | Watch this File

File Information
Description

XLS2VAR Load Excel file as variables named in the header line

  XLS2VAR(file) loads the Excel file 'file'. This file should have the variable name as a string in the first row.
  GENVARNAME is used to generate a valid MATLAB variable name from this value.
  Blanks in numeric data are returned as 'NaN'.
  Returns xlsvars which is a structure, each header (first row strings) of the Excel file is a field.

  Platform support is dependent on XLSREAD.

  example:

  Given this Excel file content (9 columns, 5 rows):

  one two three four ' ' six se ven
  1 2 3 6 7
  11 22 three
                    seven
           222 33

  xlsStruct=xls2vars('example.xls')

  Where:
      xlsStruct.one' = 1 11 NaN NaN
      xlsStruct.two' = 2 22 NaN 222
      xlsStruct.three' = [3] 'three' [NaN] [33]
      xlsStruct.four' = NaN NaN NaN NaN
      xlsStruct.x' = NaN NaN NaN NaN
      xlsStruct.six' = 6 NaN NaN NaN
      xlsStruct.seVen' = [7] [NaN] 'seven' [NaN]

  See also: xlsread genvarname

MATLAB release MATLAB 7.6 (R2008a)
Other requirements Not tested on non-windows platform.
Tags for This File  
Everyone's Tags
Tags I've Applied
Add New Tags Please login to tag files.
Please login to add a comment or rating.
Updates
29 Dec 2008

*Use dynamic structure field names instead of eval
*More flexibility for input data format in excel sheet

Tag Activity for this File
Tag Applied By Date/Time
data import Ashish Uthama 22 Oct 2008 09:59:10
data export Ashish Uthama 22 Oct 2008 09:59:10
xls excel read variables Ashish Uthama 22 Oct 2008 09:59:10
 

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