How can I specify a path to save MAT-file

2 views (last 30 days)
Hi, I am trying to import csv-file and save as mat-file. One thing I don't figure out is that the way to save mat file into a different folder from the *.m(that converts files).
[varX] = importfile(filename);
[path, name, ext] = fileparts(filename);
extention='.mat';
matname=[name extention];
save(matname) %QUESTION!! How to specify the folder?

Accepted Answer

Walter Roberson
Walter Roberson on 1 Aug 2017
Edited: Walter Roberson on 1 Aug 2017
[varX] = importfile(filename);
[filepath, name, ext] = fileparts(filename);
extention='.mat';
matname = fillefile(filepath, [name extention]);
save(matname, 'varX')

More Answers (1)

YUJI
YUJI on 1 Aug 2017
Dear Walter Roberson
Thank you very much! It helped me a lot. Small thing: fillefile() --> fullfile()

Tags

Community Treasure Hunt

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

Start Hunting!