Borrar filtros
Borrar filtros

txtファイルからス​ペース区切りで改行し​ながら、周期的にイン​ポートする方法を教え​てください。

8 visualizaciones (últimos 30 días)
K_S_
K_S_ el 13 de Sept. de 2022
Comentada: K_S_ el 14 de Sept. de 2022
現在、添付したsample.txtのようなファイルがあります。
これを、下記の形でtableにインポートしたいです。
方法をご教示願います。
00000001
00000002
00000003
00000004
00000005
00000006
00000007
00000008
00000009
00000010

Respuesta aceptada

Atsushi Ueno
Atsushi Ueno el 13 de Sept. de 2022
readtable関数を用います。
一つおきに入っている"00000000"は上位の桁とみなすのでしょうか? 下記は単に"00000000"を読み飛ばす例です。
tbl = readtable('sample.txt', ... % 読み込むファイル名
'TextType', 'string', ... % インポートされるテキストデータの型('char'|'string')
'ReadVariableNames', false, ... % 最初の行を変数名として読み取るか否か
'Delimiter',' ', ... % フィールドの区切り記号
'NumHeaderLines',4, ... % ヘッダーの行数
'Format','%s %*s') % 列の形式。%*s⇒%sに変えると"00000000"も読み込む
tbl = 10×1 table
Var1 __________ "00000001" "00000002" "00000003" "00000004" "00000005" "00000006" "00000007" "00000008" "00000009" "00000010"
  1 comentario
K_S_
K_S_ el 14 de Sept. de 2022
"00000000"は読み飛ばすことを意図していました。
意図を汲んでご回答いただきありがとうございました。

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre データのインポートと解析 en Help Center y File Exchange.

Etiquetas

Productos


Versión

R2022a

Community Treasure Hunt

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

Start Hunting!