this question about matlab:
i’m running a loop and each iteration a new set of data is produced, and I want it to be saved in a new file each time. I also overwrite old files by changing the name. Looks like this:
name_each_iter = strrep(some_source,'.string.mat','string_new.(j).mat')
and what I#m struggling here is the iteration so that I obtain files:
…string_new.1.mat
…string_new.2.mat
etc.
I was trying with various combination of () [] {} as well as ‘string_new.’j’.mat’ (which gave syntax error)
How can it be done?
For creating a name based of an already existing file, you can use regexp to detect the ‘_new.(number).mat’ and change the string depending on what regexp finds:
This does exactly that, and produces:
when iterating the above function, starting with ‘data.string.mat’