How do I save a figure to a different directory with a specific figure name?
9 ビュー (過去 30 日間)
古いコメントを表示
I am trying to save a figure with the type and dateTime variables included in the savefile name. My code uses the input variable " type = 'Triangle' " in order to run, and it saves the start time as a dateTime variable. I want the "type" variable to save based on it's input so that the saved figure will include any string assigned to "type." I am also trying to save the figure to a different directory.
I have a code that uses the variable " type = 'Triangle' " when running the code and saves the time I start running the code as f. I want to save that string variable with the date & time as part of the figure name. I'm trying to also save this figure to a different directory that my code is not in.
This is what I have so far but I am getting the following error: H must be an array of handles to valid figures.
type = 'Triangle';
folderName = 'C:\my\directory';
savefig(fullfile(folderName,[datestr(startTime) type]));
0 件のコメント
採用された回答
Fangjun Jiang
2022 年 2 月 28 日
savefig(FILENAME) saves the current figure to a file named FILENAME
savefig(H, FILENAME) saves the figures identified by the graphics
handle array H to a MATLAB figure file called FILENAME.
To be robust, specify H and make sure your file name is valid.
H=figure
plot(1:10)
savefig(H, 'myFigure')
0 件のコメント
その他の回答 (0 件)
参考
カテゴリ
Help Center および File Exchange で Interactive Control and Callbacks についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!