scriptで絶対パ​スで複数ファイルを作​成・保存する際に,フ​ァイル名の一部に指定​した文字列を一括で含​めたい

7 visualizaciones (últimos 30 días)
SK
SK el 24 de Sept. de 2020
Comentada: michio el 25 de Sept. de 2020
scriptで作成した複数のfigureを絶対パスで指定したフォルダ内に保存したい場合に,ファイル名の一部に同一文字列を一括で挿入することはできますか?
例えば,script上で「~~~_figure_1」,「~~~_figure_2」,「~~~_figure_3」という名前でfigureフォルダを作成・保存するときに,
一番最初に「Test-1」という文字列を作成しておいて,「~~~」の部分を一括で「Test-1」に置換して「Test-1_figre_1」といったファイルを作成・保存することは出来るでしょうか?
savefig('C\Useres\Documents\保存先フォルダ名\~~~_figure_1)
などとコマンド保存しようとすると'C\以降は文字列認識のためうまく挿入等ができませんでした.

Respuestas (1)

michio
michio el 24 de Sept. de 2020
正規表現を使ってもよいですが、string 型の操作で例えば以下のようなことはできますが、用途に合いそうでしょうか?
>> str = ["asdfadsfa_figure_1", "asdfasdgfd_figure_2", "wergrgafasd_figure_3"]
str =
1×3 string 配列
"asdfadsfa_figure_1" "asdfasdgfd_figure_2" "wergrgafasd_figure_3"
>> "Test-1" + "_figure" + extractAfter(str,"figure")
ans =
1×3 string 配列
"Test-1_figure_1" "Test-1_figure_2" "Test-1_figure_3"
  2 comentarios
SK
SK el 25 de Sept. de 2020
教えていただいたstring配列を色々といじってみてたところ,やりたいことができるようになりました.
大変助かりました.
どうもありがとうございました.
michio
michio el 25 de Sept. de 2020
よかったです!

Iniciar sesión para comentar.

Categorías

Más información sobre Text Analytics Toolbox en Help Center y File Exchange.

Productos


Versión

R2019a

Community Treasure Hunt

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

Start Hunting!