アプリケーションコン​パイラー→パッケージ​化→アプリケーション​ソフト(.exe)を​起動してもエラーが発​生

下記内容でAAA(添付zipファイル参照)のフォルダをリスト化し、リストしたテキストデータをcsvに落とすアプリケーションを作りたいです。ライブスクリプトでは問題なく動きますが、アプリケーションコンパイラー→パッケージ化→アプリケーションソフト(.exe)で作ったアプリケーションソフトを起動すると「'1.txt'が見つかりません。・・・」とエラーがでます。
対処方法を教えていただけないでしょうか。よろしくお願いします。
List = dir('AAA/*.txt')
List = 0×1 empty struct array with fields: name folder date bytes isdir datenum
for n = 1:length(List)
List1{n} = readcell(List(n).name)
List2 = cat(1,List1{1:n})
end
writecell(List2,"List.csv")
Unrecognized function or variable 'List2'.

 Respuesta aceptada

Kojiro Saito
Kojiro Saito el 24 de Sept. de 2021

2 votos

List(n).nameにはファイル名(例:1.txt)しか含まれませんので、exeファイルと同じフォルダ階層に1.txtと2.txtが置かれている必要があります。
AAAフォルダに1.txtなどがあるとのことなので、fullfileを付けてフォルダ名を含むファイルパスを指定してみてはいかがでしょうか?
List = dir('AAA/*.txt')
for n = 1:length(List)
List1{n} = readcell(fullfile(List(n).folder, List(n).name))
List2 = cat(1,List1{1:n})
end
writecell(List2,"List.csv")
また、アプリケーションコンパイラでexeにした後、exeと同じフォルダにAAAを置く必要があります。

1 comentario

丈太郎 森川
丈太郎 森川 el 27 de Sept. de 2021
早速のご回答ありがとうございます!
こちらで出来ました。
今後ともよろしくお願いいたします。

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre MATLAB Compiler en Centro de ayuda y File Exchange.

Productos

Versión

R2021b

Preguntada:

el 24 de Sept. de 2021

Comentada:

el 27 de Sept. de 2021

Community Treasure Hunt

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

Start Hunting!