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일
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.

카테고리

도움말 센터File Exchange에서 Annotations에 대해 자세히 알아보기

질문:

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