Reputation: 3289
I want to know the best way of importing both number and non-numeric data (which is string in the present case) from an excel file into MATLAB? By best (or better) way, I mean all the data together in a variable (or data structure).
First, I tried uiopen(filename) function which opens a wizard and from there, I can import the data into a MATLAB variable. However, problem here is that it replaces all the non-numeric data with zeros which is not required. I later on, found that this function calls another function, named xlsread(filename), which is another way (actual way) of importing excel file.
Second (last) way that I tried (which seems to be better) is to use function called importdata(filename) which imports both numeric and non-numeric data into separate structure variables.
However, I am wondering if there exists some other way(s) to import everything into a single variable or data structure?
Upvotes: 0
Views: 2369
Reputation: 13876
xlsread
is the correct way to import data from Excel spreadsheets,both numeric and non-numeric data. Check the documentation:
[num,txt,raw] = xlsread(___)
additionally returns the text fields in cell arraytxt
, and the unprocessed data (numbers and text) in cell arrayraw
using any of the input arguments in the previous syntaxes. IfxlRange
is specified, leading blank rows and columns in the worksheet that precede rows and columns with data are returned inraw
.
Upvotes: 2