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

9 Ansichten (letzte 30 Tage)
雄大
雄大 am 22 Jun. 2022
Beantwortet: Kojiro Saito am 23 Jun. 2022
readcell()によってテキストファイルをarray化するとき、"," (コンマ)ではなく" "(スペース)で区切りたいのですがどうすればよいでしょうか

Antworten (1)

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

Tags

Produkte

Community Treasure Hunt

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

Start Hunting!