Effacer les filtres
Effacer les filtres

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 vues (au cours des 30 derniers jours)
% 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 commentaires
Dyuman Joshi
Dyuman Joshi le 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?

Connectez-vous pour commenter.

Réponse acceptée

Walter Roberson
Walter Roberson le 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.

Plus de réponses (0)

Catégories

En savoir plus sur Data Import from MATLAB dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by