Change variable name in a loop
13 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
gaetano mallardo
le 8 Avr 2019
Modifié(e) : madhan ravi
le 8 Avr 2019
I want to call a function in a loop which gives me a 3xn matrix and i want to call the matrix model_(number)
for i=1:length(Domain)
model=IDtriang(trianglesN,Domain,i);
so if length=7 i would like to store 7 matrix like variables as
Model_1
Model_2
Model_3
I know i can do it saving it, but than i should call it back and i don't need it as i have to work with it
0 commentaires
Réponse acceptée
madhan ravi
le 8 Avr 2019
Modifié(e) : madhan ravi
le 8 Avr 2019
Naming variables is not a good idea so store it as a cell array ( https://in.mathworks.com/matlabcentral/answers/304528-tutorial-why-variables-should-not-be-named-dynamically-eval )
model = cell(1,length(Domain)); % before loop
model{i}=IDtriang(trianglesN,Domain,i);
0 commentaires
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!