How to display the filename correctly?
조회 수: 7 (최근 30일)
이전 댓글 표시
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
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')
추가 답변 (0개)
참고 항목
카테고리
Help Center 및 File Exchange에서 Whos에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!