HOW CAN I MODIFY THE PATH WHERE MATLAB SAVE A FILE USING THE FUNCTION 'PRINT'?

4 views (last 30 days)
h = figure; plot(1:4,5:8); path=uigetdir('C:\'); print(h,'-dpdf',report,'-r600');
%I want to save this file 'report.pdf' in the directory define by 'path'.. I don't know how to do it...

Accepted Answer

John D'Errico
John D'Errico on 24 Aug 2015
It is a really bad idea to name variables with the same name as a useful function. Here it is the name path.
As for saving the file to a specific directory. READ THE HELP FOR PRINT. You can specify the filename.
print -device -options filename
If you specify a filename, MATLAB directs output to a file instead of
a printer. print adds the appropriate file extension if you do not
specify one.
If that filename has a path attached to it, where do you think the file will appear? Of course.

More Answers (0)

Categories

Find more on Search Path in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!