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

readcell()によってテキストファイルをarray化するとき、"," (コンマ)ではなく" "(スペース)で区切りたいのですがどうすればよいでしょうか

Respuestas (1)

Kojiro Saito
Kojiro Saito el 23 de Jun. de 2022

0 votos

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

Productos

Etiquetas

Preguntada:

el 22 de Jun. de 2022

Respondida:

el 23 de Jun. de 2022

Community Treasure Hunt

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

Start Hunting!