MATLAB: Save workspace with same load file name MATLABsave How to save matlab workspace automatically with same load file name? Thank you Best Answer 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') Related SolutionsMATLAB: MAT files p=load matfile1.matq=load matfile2.matsave newmatfile.mat MATLAB: Saving all of workspace in a specified folder Saving to pathsave('path\myfile.mat');Example: save('D:\WORKING\Myfile.mat');Loading from a pathload('path\myfile.mat');Example: load('D:\WORKING\Myfile.mat'); Related QuestionHow to pass a “.mat” file as an argument of user defined functionSaving an imported.txt file as .mat file in a for loop using the same original file nameSelect an unknown variable from .Mat fileQuestion regarding ‘copyfile’ function from folder to folder
Best Answer