Plotting different graphs for different variables using loops
Mostrar comentarios más antiguos
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 comentario
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.
Respuestas (1)
Star Strider
el 22 de Mzo. de 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.
Categorías
Más información sobre Annotations en Centro de ayuda y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!