Borrar filtros
Borrar filtros

Info

La pregunta está cerrada. Vuélvala a abrir para editarla o responderla.

Running the files on a sequence, saving the results, running the files again, saving the results with different name

1 visualización (últimos 30 días)
Hi,
I use a .m file with just diary function in it to run several different files sequentially in the same folder. diary log1.txt;file1;clear variables diary log2.txt;file2;clear variables diary log3.txt;file3;clear variables
File 1 ends with: save('result1','variable1','variable2')
File 2 ends with: save('result2','variable3','variable4')
Same reasoning for file 3. How can I run the 3 files 50 times and save the results in different files for each run. Or save in the same file without overwritting, which I think would be more difficult. For example: saving: first run: results1_1 results2_1 results3_1
second run: results1_2 results2_2 results3_2
...
for 50 runs
Thank you very much.

Respuestas (1)

Jayaram Theegala
Jayaram Theegala el 14 de Nov. de 2016
For creating your "results" files for 50 runs, you can create a for-loop for 50 iterations and the "results1_1", "results2_1", "results3_1" can be created in first iteration and "results1_2", "results2_2", "results3_2" can be created in second iteration and so on.
For creating the file names dynamically, you can create them based on the iteration number. The following MATLAB code can illustrate the above point:
for i = 1:50
diary(['results1_', num2str(i),'.txt']); %dynamically creating the file name
disp('Hello'); %replace this line with the code you are calling
diary off;
end
The above MATLAB code creates 50 files by names: "results1_1.txt", "results1_2.txt", ... "results1_50.txt". You can add all the files you want to run within the for-loop and those files will be run for 50 times.
Hope this helps.

La pregunta está cerrada.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by