필터 지우기
필터 지우기

how can i store the result which i am obtaining on command window and store it on in excel file, i have tried but still not able to solve it out.

조회 수: 3 (최근 30일)
% Initialize variables
numIterations = 10;
outputResults = zeros(10, numIterations);
% Perform iterations
for iteration = 1:numIterations
% Generate random results for each iteration
result = rand(10, 1);
run('start.m'); % my main program to be run for 10 iterations%
% Store results in outputResults matrix
outputResults(:, iteration) = result;
end
% Create a table from the outputResults matrix
resultsTable = array2table(outputResults);
% Export to Excel
writetable(resultsTable,'resultsTable.xls')
  댓글 수: 4
Dyuman Joshi
Dyuman Joshi 2023년 11월 27일
Why not define the code as a function and provide the data you want to save in terms of output variable(s)?
This way you can call the function in each iteration and store the data accordingly.
What is it, that is displayed on the command window which you want to capture?

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

채택된 답변

Walter Roberson
Walter Roberson 2023년 11월 26일
If you cannot modify the script for some reason, then change
run('start.m'); % my main program to be run for 10 iterations%
to
start_results = evalc('start');
and then use tools such as regexp() to extract the parts you want out of the output.
But if you can modify the script to return a value, that would almost always be better.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Data Import from MATLAB에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by