Save multiple run result of script

조회 수: 9 (최근 30일)
yh sf
yh sf 2017년 11월 20일
편집: Stephen23 2020년 1월 1일
Hi i'm writing a code with matlab, i wonder if there is a way to save the result of my script every time i run it.Example if i run this code multiple times i want to get all different outputs in my vector or file in case of using save function.
s=[];
s=fitness(D,vect);
Because every time i execute, it overwrites the last result.
Thank you.

채택된 답변

KL
KL 2017년 11월 20일
편집: KL 2017년 11월 20일
EDITED
numOfRuns = 5;
for n=1:numOfRuns
s = fitness(D,vect);
save(['result_data_run_number_' num2str(n) ',mat'],'s');
end
  댓글 수: 5
KL
KL 2017년 11월 20일
You will get different results only if you change some of your code. I only showed you how to run a code multiple times and store the outcome in different mat files.
Put the part of the code you want to repeat inside for loop and save should be at the end of the loop.
yh sf
yh sf 2017년 11월 20일
Thank you, my fault, so obvious but i was stuck with the idea that i have to click on the run button every time.

댓글을 달려면 로그인하십시오.

추가 답변 (1개)

Stephen23
Stephen23 2017년 11월 20일
편집: Stephen23 2020년 1월 1일
An alternative to using a loop: download my FEX submission nextname, which will generate the next name each time you call it. Simply put this in your script to generate the filename:
name = nextname('result','_1','.mat')

카테고리

Help CenterFile Exchange에서 Java Package Integration에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by