How to create multiple graphs based on a variable that goes into a for-loop?

Hello Community,
I want to plot multiple graphs into one figure.
The multiple graphs are based on different geometry inputs, i.e. 4 graphs needed for 4 different
The different geometry inputs are used in a loop for B:
I can find the result for every single geometry input, which is fine:
How can I create several graphs for several geometry inputs at the same time?
Thank you very much

2 件のコメント

Vladimir Sovkov
Vladimir Sovkov 2020 年 6 月 27 日
use "hold" command
GettinStarted
GettinStarted 2020 年 6 月 27 日
Hi Vladimir,
thank you for the quick answer.
I know the "hold" command, but I guess this would mean, that I have to create new loops for every different geometry input. So if I want to plot 4 graphs for 4 different geometry inputs this would need 4 loops at the same time.
Is there a more elegant way to do it?

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

 採用された回答

darova
darova 2020 年 6 月 28 日
Maybe you need only one more for loop
expansion = [1 2 3 4];
x = 0:10;
% data
for k = 1:length(expansion)
y = sin(x)*expansion(k);
line(x,y)
end

3 件のコメント

GettinStarted
GettinStarted 2020 年 6 月 28 日
Hi darova,
thank you very much for your help. I think this is going into the right direction.
Maybe u can help me furth with the specific problem:
This is the input. Let's say I want results for R_expansion = 0.12 and R_Rexpansion = 0.2 and R_expansion = 0.3
So this is my loop, where the yellow marked input is:
Can you give it another try?
darova
darova 2020 年 6 月 29 日
Here is another try
GettinStarted
GettinStarted 2020 年 6 月 29 日
Hello davora,
thank you very much for your help.

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

その他の回答 (0 件)

カテゴリ

ヘルプ センター および File ExchangeLoops and Conditional Statements についてさらに検索

製品

リリース

R2020a

Community Treasure Hunt

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

Start Hunting!

Translated by