txtファイルからスペース区切りで改行しながら、周期的にインポートする方法を教えてください。
6 views (last 30 days)
Show older comments
現在、添付したsample.txtのようなファイルがあります。
これを、下記の形でtableにインポートしたいです。
方法をご教示願います。
00000001
00000002
00000003
00000004
00000005
00000006
00000007
00000008
00000009
00000010
0 Comments
Accepted Answer
Atsushi Ueno
on 13 Sep 2022
readtable関数を用います。
一つおきに入っている"00000000"は上位の桁とみなすのでしょうか? 下記は単に"00000000"を読み飛ばす例です。
tbl = readtable('sample.txt', ... % 読み込むファイル名
'TextType', 'string', ... % インポートされるテキストデータの型('char'|'string')
'ReadVariableNames', false, ... % 最初の行を変数名として読み取るか否か
'Delimiter',' ', ... % フィールドの区切り記号
'NumHeaderLines',4, ... % ヘッダーの行数
'Format','%s %*s') % 列の形式。%*s⇒%sに変えると"00000000"も読み込む
More Answers (0)
See Also
Categories
Find more on スプレッドシート in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!