Save workspace with same load file name
5 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Setiadi Suriana
am 14 Dez. 2020
Kommentiert: Rik
am 29 Apr. 2022
How to save matlab workspace automatically with same load file name? Thank you
2 Kommentare
Akzeptierte Antwort
Rik
am 14 Dez. 2020
You can use code like this in a loop.
file_name_including_dot_txt='example.txt';
data=function_that_reads_your_file(file_name_including_dot_txt);
[p,fn]=fileparts(file_name_including_dot_txt);
matfilename=fullfile(p,[fn '.mat']);
save(matfilename,'data')
2 Kommentare
Little Flower
am 28 Apr. 2022
Hello Rik, if I want to save it in a folder how can i change the last line of your code? kindly clarify
Rik
am 29 Apr. 2022
Edit the second to last line. That is where the location and file name is determined. What exactly do you mean by saving in a folder?
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu File Operations finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!