フィルターのクリア

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 Center および File ExchangeData Import from MATLAB についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by