save plot in folder

2 visualizzazioni (ultimi 30 giorni)
Christos Tsouknidas
Christos Tsouknidas il 3 Mag 2015
Hello, In order to save some time writing my thesis I would like to make an function that has an input the folder name and the figure name in order to save automatically the plots from matlab. Normally I save using the command:
print('-depsc','C:\Users\Lenovo\Dropbox\THESIS\Latex\graphics\Chap2\wind.eps');
Can you please help me how I can write the function? I tried this but does not work.
function [ output_args ] = saveAsEps( folderName, fileName )
eval(['print -depsc ,C:\Users\Lenovo\Dropbox\THESIS\Latex\graphics\,'num2str(folderName),'\',num2str(fileName)','.eps']);
end
Thanks!

Risposte (2)

Image Analyst
Image Analyst il 3 Mag 2015

Jan
Jan il 3 Mag 2015
"It doesn't work" is not a useful description. Better post the error messages or explain the difference between the results and your expectations.
What about this:
function saveAsEps(folderName, fileName)
print('-depsc', ...
fullfile('C:\Users\Lenovo\Dropbox\THESIS\Latex\graphics\', ...
folderName, [fileName, '.eps']));
end
Avoid eval under all circumstances, because there is always a better method. num2str is not useful here - most likely. There was a comma in the path inside the eval argument.
  1 Commento
Christos Tsouknidas
Christos Tsouknidas il 3 Mag 2015
Yes!! Thanks a lot guys! Jan Simon was answer was almost correct! I made one small change. I call the function like this : saveAsEps( 'Chap1' ,'wind' )
function [ output_args ] = saveAsEps( folderName,fileName )
print('-depsc', ...
fullfile('C:\Users\Lenovo\Dropbox\THESIS\Latex\graphics\',[folderName ...
,'\', fileName, '.eps']));
end

Accedi per commentare.

Categorie

Scopri di più su Data Type Conversion in Help Center e File Exchange

Prodotti

Community Treasure Hunt

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

Start Hunting!

Translated by