How do I save a figure as a png to a different directory?
63 ビュー (過去 30 日間)
古いコメントを表示
I need help saving my figure to a different directory than the one I'm running my code in. The directory I want to save it to is /Volumes/Expansion/dispersion.
This is what I have so far. I'm not sure how to incorporate the directory I want to save the figure to.
header = 'title of figure on plot';
print(gcf,header,'-dpng','-r300');
0 件のコメント
採用された回答
Jon
2021 年 10 月 29 日
x = [1 2 3]
y = x.^2
plot(x,y)
exportgraphics(gcf,'/Volumes/Expansion/dispersion/myplot.jpg')
5 件のコメント
Jon
2021 年 10 月 29 日
編集済み: Jon
2021 年 10 月 29 日
If you just want to use the print command as you have started, you just have to append the path to the filename so:
filename = 'myfile'
name = fullfile('Volumes','Expansion','dispersion',filename)
print(name,'-dpng','-r300')
In the above I also built the filename programatically in case you wanted to do that
その他の回答 (0 件)
参考
カテゴリ
Help Center および File Exchange で File Operations についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!