Plotting different graphs for different variables using loops

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 件のコメント

Stephen23
Stephen23 2017 年 3 月 22 日
編集済み: Stephen23 2017 年 3 月 22 日
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.

サインインしてコメントする。

回答 (1 件)

Star Strider
Star Strider 2017 年 3 月 22 日

0 投票

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.

カテゴリ

質問済み:

2017 年 3 月 22 日

回答済み:

2017 年 3 月 22 日

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by