Azzera filtri
Azzera filtri

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 visualizzazioni (ultimi 30 giorni)
% 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 Commenti
Dyuman Joshi
Dyuman Joshi il 27 Nov 2023
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?

Accedi per commentare.

Risposta accettata

Walter Roberson
Walter Roberson il 26 Nov 2023
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.

Più risposte (0)

Categorie

Scopri di più su Data Import from MATLAB in Help Center e File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by