Maintain values inside loop
2 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
Ancalagon8
le 12 Déc 2022
Modifié(e) : Ancalagon8
le 6 Jan 2025
I need help debugging part of my code, from data i want to create timetables one for each class. Right now the result shows only the last class without keeping the previous ones.
Any ideas how to correct the loop?
0 commentaires
Réponse acceptée
Bora Eryilmaz
le 12 Déc 2022
Modifié(e) : Bora Eryilmaz
le 12 Déc 2022
Store the results in a vector of results instead of just keeping a scalar result for the last one. See the "{i}" index below:
for i = 1:12
resultsperMonth_{i} = timetable(Datespermonth{i,1},dataperMonth{i,1})
end
You can do something like this:
A = {};
for i = 1:5
A{i} = timetable;
end
A
3 commentaires
Bora Eryilmaz
le 12 Déc 2022
Modifié(e) : Bora Eryilmaz
le 12 Déc 2022
Then, you can use a cell array to store the results. I've updated the code above.
Plus de réponses (0)
Voir également
Catégories
En savoir plus sur Loops and Conditional Statements 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!