Saveas plot using name of imported data file.

조회 수: 4 (최근 30일)
Samir
Samir 2014년 6월 13일
댓글: Samir 2016년 3월 7일
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.

채택된 답변

Dishant Arora
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

추가 답변 (1개)

Mischa Kim
Mischa Kim 2014년 6월 13일
Samir, how about
[pathstr,name,ext] = fileparts(filev);
f = fullfile(pathstr,name);
saveas(gcf,f)
  댓글 수: 1
Samir
Samir 2016년 3월 7일
Thank you very much Mischa, it works.

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Data Import and Analysis에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by