Clear Filters
Clear Filters

save a figure in a predefined folder as variable using print

3 views (last 30 days)
Hi, there is a way to save a specific image (like figure 1 in the example below denoted as '-f1') in a specific folder a using the command “print” as follows:
print('-f1',filename,'-dpng')
where:
filename='EXAMPLE'
Figure1 is a random plot
What is missing here is the path where to save the png image which can be defined like this:
Saved_folder='D:\Main folder \Subfolder \Folder_test'
I would appreciate any help

Accepted Answer

Star Strider
Star Strider on 24 Nov 2023
Using the fullfile function may help. You have to supply the necessary information, however fullfile will build the path.
  2 Comments
Jorge Luis Paredes Estacio
filename1=fullfile(Saved_folder,filename);
print('-f1',filename1,'-dpng');
It worked perfectly. Thank you very much :)

Sign in to comment.

More Answers (0)

Categories

Find more on Convert Image Type in Help Center and File Exchange

Products


Release

R2021a

Community Treasure Hunt

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

Start Hunting!