Saveas plot using name of imported data file.
1 次查看(过去 30 天)
显示 更早的评论
I have a data file named ex1.csv that I imported and plotted the data. I want to write a script which save this plot using same file name as input data file.
I have in workspace file name as
filev= 'I:\windows\users\me\desktop\data\ex1.csv'
which is imported some how, now I want to use something like
saveas(gcf,filev,'fig')
So that it saves ex1.fig file to exact same location as that of imported file with same file name and different extension(Ofcourse).
Above command does not work it tries to overwrite same file.
0 个评论
采纳的回答
Dishant Arora
2014-6-13
编辑:Dishant Arora
2014-6-13
[path , name , ext] = fileparts(filev);
saveas(gcf , fullfile(path , [name , '.jpg']))
% You can change the path you want to save in
0 个评论
更多回答(1 个)
Mischa Kim
2014-6-13
Samir, how about
[pathstr,name,ext] = fileparts(filev);
f = fullfile(pathstr,name);
saveas(gcf,f)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Printing and Saving 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!