Print figure to a specific path

16 vues (au cours des 30 derniers jours)
JP Connors
JP Connors le 6 Avr 2017
Commenté : JP Connors le 8 Avr 2017
Hi,
I'm using MATLAB version R2016a on a Mac and I'm having trouble printing a figure to a different directory than the current one. Could someone please help me fix my mistake? I have tried the following code:
print('Ult_Stress_vs_Temp','-dpng','/Users/Tim/Documents/2-Grad-School/Research/Technical-Paper/Latex/Figures/')
This is the error message I receive:
Error using inputcheck (line 40)
Multiple inputs that look like file names: 'Ult_Stress_vs_Temp' and
'/Users/Tim/Documents/2-Grad-School/Research/Technical-Paper/Latex/Figures/'.
Error in print (line 41)
[pj, devices, options ] = inputcheck( pj, inputargs{:} );
Error in ult_stress_temp_plot (line 47)
print('Ult_Stress_vs_Temp','-dpng','/Users/Tim/Documents/2-Grad-School/Research/Technical-Paper/Latex/Figures/')
>>

Réponse acceptée

Les Beckham
Les Beckham le 6 Avr 2017
You need to pass a handle to the figure you wish to print. The parameter 'Ult_Stress_vs_Temp' is, I assume, maybe the title of the plot? This will not work. Ideally you will have created a handle to the figure when you created it (hfig = figure; plot(x,y), or similar).
You then print as: print(hfig, '-dpng', '/Users/Tim/Documents/2-Grad-School/Research/Technical-Paper/Latex/Figures/Ult_Stress_vs_Temp.png'). Note that you need to provide the filename, not just a folder location.
  1 commentaire
JP Connors
JP Connors le 8 Avr 2017
Thanks for your help!!

Connectez-vous pour commenter.

Plus de réponses (0)

Catégories

En savoir plus sur MATLAB Report Generator dans Help Center et File Exchange

Produits

Community Treasure Hunt

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

Start Hunting!

Translated by