Effacer les filtres
Effacer les filtres

Saving timetable for each iteration

2 vues (au cours des 30 derniers jours)
Sharanya
Sharanya le 9 Juil 2023
Commenté : Sharanya le 9 Juil 2023
In the code below, a simulink model runs 10 times and a table is extracted in each iteration and stored in the variable y. How do I save these tables in each iteration? (It would also be better if I could just write all of them off into one separate table).
for i=1:10
sampletime = iter(i);
simOut = sim("new_conflict_detect.slx");
y = timetable2table(ts2timetable(simOut.logsout{2}.Values));
end
Just for an idea, one of the tables looks like this:

Réponse acceptée

rakshit gupta
rakshit gupta le 9 Juil 2023
You can cell function to create an empty cell array to store the tables.
tables = cell(1, 10);
for i = 1:10
sampletime = iter(i);
simOut = sim("new_conflict_detect.slx");
y = timetable2table(ts2timetable(simOut.logsout{2}.Values));
% Save the table in the cell array
tables{i} = y;
end
% Save the cell array as a .mat file
save('tables.mat', 'tables');
  1 commentaire
Sharanya
Sharanya le 9 Juil 2023
This worked! Thanks a lot.

Connectez-vous pour commenter.

Plus de réponses (0)

Catégories

En savoir plus sur Simulink Functions dans Help Center et File Exchange

Produits


Version

R2022b

Community Treasure Hunt

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

Start Hunting!

Translated by