I have an excel file, which is a mix of text file and numerical values. For instance, the file look like this,
开发者_如何学C25 file1
26 file2
Here the 25 is an numerical value in the first cell (row 1, column1). "file1" represents the content in the second cell(row1, column2). It can be short text file composed of multiple paragraphs.
I want to load this excel file into matlab, and store it into a 2*2 matrix. Each matrix entry corresponds to a matrix cell.
I tried xlsread
, but it did not work. I also tried textscan
, but it seems to be able to handle the scenario where a cell has a string only. Here, the contents of some cells are text files itself.
If you are reading an Excel file using XLSREAD, you can use the third output argument to retrieve the both the textual and numeric data (unprocessed).
Example:
>> [~,~,raw] = xlsread('Book1.xls')
raw =
[25] 'hello world.'
[26] [1x38 char]
>> raw{2,2}
ans =
this is an example
of multi-line
text
Note that XLSREAD is limited to the capabilities of MS Excel to open/read files, so some especially large files (in my experience 1 million+ rows) will get only partially read.
精彩评论