Plotting different graphs for different variables using loops
Afficher commentaires plus anciens
How do I plot different variables such as: qq1, qq2, qq3, qq4, qq5 in different plots using a loop? Say these qq terms contain values. Could I use a for loop?
1 commentaire
Please read the MATLAB documentation, which states "A frequent use of the eval function is to create sets of variables such as A1, A2, ..., An, but this approach does not use the array processing power of MATLAB and is not recommended."
Here are some pages that explain why accessing variable names dynamically is a bad idea:
You should use indexing: indexing is much more efficient, easier to use, faster, much less buggy, and much less obfuscated than any hack code that accesses the variable names dynamically.
Réponses (1)
Star Strider
le 22 Mar 2017
First, rename them as elements of a cell array, such as:
qq{1} = ...;
qq{2} = ...;
Then you can use a loop. Note the curly brackets ‘{}’ denoting cell array indexing.
Catégories
En savoir plus sur Annotations dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!