Can I put an fprint statement in a saveas command?

5 views (last 30 days)
So I have about 15 different sets of data that all have to go through the same exact code and spit out roughly 40 figures. I need to save these figures as fig files and jpgs. Each figure has the same begining filename except at the end where the name deviates to explain which data set it comes from. What I want to do is assign this last part of the name to a variable and call that variable in the saveas command so I don't need to go through hundreds of lines of saveas commands and manually enter in the last part of the filename. I tried to use an fprint statement and it just displays "fprint(variable)" in the filename.

Answers (1)

Jan
Jan on 18 Jun 2021
folder = 'D:\Your\Output';
n = 4;
saveas(FigH, fullfile(folder, sprintf('File%03d.eps', n)));
This creates the file: D:\Your\Output\File004.eps

Categories

Find more on Printing and Saving in Help Center and File Exchange

Products


Release

R2020a

Community Treasure Hunt

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

Start Hunting!