テキストファイルをス​ペースで区切り、ar​ray化する方法を教​えてください。

7 ビュー (過去 30 日間)
雄大
雄大 2022 年 6 月 22 日
回答済み: Kojiro Saito 2022 年 6 月 23 日
readcell()によってテキストファイルをarray化するとき、"," (コンマ)ではなく" "(スペース)で区切りたいのですがどうすればよいでしょうか

回答 (1 件)

Kojiro Saito
Kojiro Saito 2022 年 6 月 23 日
readcellのドキュメントによると、テキスト ファイルの場合はDelimiterのオプションが指定できますので、以下のようにオプションを指定すれば可能です。
t = readcell('mytext.txt', 'Delimiter', ' ');
上記でうまくいかなかったらdetectImportOptionsでオプションを指定することで可能です。
opts = detectImportOptions('mytext.txt');
opts.Delimiter = ' ';
t = readcell('mytext.txt', opts);

タグ

製品

Community Treasure Hunt

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

Start Hunting!