Can I put an fprint statement in a saveas command?

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.

Risposte (1)

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

Prodotti

Release

R2020a

Richiesto:

il 17 Giu 2021

Risposto:

Jan
il 18 Giu 2021

Community Treasure Hunt

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

Start Hunting!

Translated by