フィルターのクリア

How to display the filename correctly?

4 ビュー (過去 30 日間)
Jay Vaidya
Jay Vaidya 2020 年 10 月 4 日
コメント済み: Stephen23 2020 年 10 月 4 日
I am trying to export a figure with a file name that is derived from the string name after a section of a code. Below is the export fig part. But for some reason, instead of printing the actual name of string the code prints fig_name as the file name. What can be done to avoid this?
p1 = strfind(fname,'.csv');
fig_name = string(fname(1:1:p1-1));
fig_name = sprintf(fig_name + '.png')
%% export the figure
export_fig fig_name -transparent

採用された回答

Ameer Hamza
Ameer Hamza 2020 年 10 月 4 日
編集済み: Ameer Hamza 2020 年 10 月 4 日
You are using the command format of export_fig. MATLAB does not understand fig_name is used to refer a variable and just consider it as a string. Use the functional format
export_fig(fig_name, '-transparent')
  1 件のコメント
Jay Vaidya
Jay Vaidya 2020 年 10 月 4 日
Thanks

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeString Parsing についてさらに検索

製品


リリース

R2020b

Community Treasure Hunt

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

Start Hunting!

Translated by