how to import an excel or txt file with multiple columns of 'strings'

2 ビュー (過去 30 日間)
George McFadden
George McFadden 2012 年 7 月 3 日
I have an excel file with 347 rows and 5 columns of strings. Each string in a cell has single quotes around it. For example:
'FS-SW 7/27' 'frogstool' 'fs3' 'center' 'recon'
'FS3-10' 'frogstool' 'fs3' 'center' 'recon'
'FS3-26' 'frogstool' 'fs3' 'center' 'recon'
'PUN-SW 7/27' 'pungos' 'pun1' 'center' 'recon'
'PUN1-10' 'pungos' 'pun1' 'center' 'recon'
'PUN1-23' 'pungos' 'pun1' 'center' 'recon'
How do I load this into Matlab as a cell array ideally? I need the data to be entered in the same matrix dimensions, (347,5). I am going to horizontally concatenate it with a numeric array into a dataset eventually.
Thanks in advance!
-1waytimemachine

採用された回答

Walter Roberson
Walter Roberson 2012 年 7 月 3 日
Possibly
[num, txt] = xlsread('YourFile.xls');
Then txt should be the cell array.
  2 件のコメント
George McFadden
George McFadden 2012 年 7 月 3 日
> Walter, xlsread worked, thank you! I used [txt,raw] = xlsread...
The text variable contains nothing, but the raw contains the data. Load, and import data were not working for me. Thanks again.
Walter Roberson
Walter Roberson 2012 年 7 月 3 日
Selection of output is positional, not by variable name. The first output of xlsread() is always the numeric array, even when no understandable numbers were found.

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeSpreadsheets についてさらに検索

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by