Print matrices whose name is based on loop values
1 vue (au cours des 30 derniers jours)
Afficher commentaires plus anciens
Paras Choudhary
le 21 Juil 2022
Réponse apportée : Steven Lord
le 21 Juil 2022
for i = 1:3
eval(['k' num2str(i) '=i']);
end
%% Doubt - How to print k1, k2, k3 based on iteration no. ???
0 commentaires
Réponse acceptée
Steven Lord
le 21 Juil 2022
Can you dynamically create variables with numbered names like k1, k2, k3, etc.? Yes.
Should you do this? The general consensus is no. That Answers post explains why this is generally discouraged and offers several alternative approaches.
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!