How do I import text from a text file in matlab?

1 回表示 (過去 30 日間)
tban
tban 2017 年 9 月 20 日
コメント済み: Rena Berman 2019 年 4 月 2 日
I have a list like this in a MacBook text file.
frame
picture
wall
room
house
I want to import it in Matlab and use every word in a loop. How do I import the list so I can use it from another handle?
I know how to use it in the loop after I get lenght of matrix and make a loop from 1:end.
  2 件のコメント
MATLAB Newbie
MATLAB Newbie 2017 年 9 月 20 日
Possibly textscan to place all words into a cell, but the page is down at the moment so I can't confirm if textscan is correct.
Rena Berman
Rena Berman 2019 年 4 月 2 日
(Answers Dev) Restored edit

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

回答 (1 件)

Walter Roberson
Walter Roberson 2017 年 9 月 20 日
S = regexp( fileread('TheFileName'), '\s+', 'split')
Now S is a cell array of the words in the file

カテゴリ

Help Center および File ExchangeData Import and Export についてさらに検索

タグ

製品

Community Treasure Hunt

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

Start Hunting!

Translated by