How to define a path in saveas command?
显示 更早的评论
Hey Matlab users,
I've got a problem in defining a path for saveas command. When i want to save my Figure, the file is directly been saved in a path that is already on top of the command window in front of the "Current Folder". I tried to change the address by fname:
fname = 'D:\path1\path2';
saveas(gca,filename,'jpeg');
But it didn't work!!!
I very much appreciate your hint :) Mehdi
采纳的回答
更多回答(1 个)
Wayne King
2011-10-6
You can either change directory to the directory you want to save it in, or you can specify the directory
plot(randn(100,1));
save(gca,'c:\figures\test','jpeg');
2 个评论
Wayne King
2011-10-6
Also if you want to define your figures directory
figuresdir = 'D:\figures\';
saveas(gcf,strcat(figuresdir, 'filename'), 'jpeg');
adams13
2021-1-12
Instead of 'strcat' it is better to use the 'fullfile' function because it will handle the file separator and will work in different operating systems (will place correctly '\' in Windows, '/' in Linux etc.)
saveas(gcf, fullfile(figuresdir, 'filename'), 'jpeg');
类别
在 帮助中心 和 File Exchange 中查找有关 EEG/MEG/ECoG 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!