简体   繁体   中英

Print a MATLAB figure to a specific directory

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/')

Can someone tell me what I'm doing wrong?

When I run this I get the following error:

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/') 
>>

You need to specify the full file path as the first argument. It's also recommended that you construct your file paths using fullfile to better deal with differences between operating systems.

filename = fullfile('/Users/Tim/Documents/2-Grad-School/Research/Technical-Paper/Latex/Figures/', 'Ult_Stress_vs_Temp');

print(filename, '-dpng')

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM