Plotting multiple curves in same graph

3 ビュー (過去 30 日間)
Chinmayraj Doddarajappa
Chinmayraj Doddarajappa 2022 年 8 月 16 日
コメント済み: Star Strider 2022 年 8 月 17 日
Hello,
I am working on a script. The graph below must be plotted for all the values of N (N varies between 1 and +ve number). Now what is happening is if I run the script, for every iteration of N, values are plotted on to a new graph.
Instead, it would be really helpful if someone can check the script and help me to plot all the curves on to a single graph. I have attached the script. (Below is the expectation of the graph to look like)
Thanks in advance for your time.

回答 (1 件)

Star Strider
Star Strider 2022 年 8 月 17 日
See if the hold function will do what you want.
  2 件のコメント
Chinmayraj Doddarajappa
Chinmayraj Doddarajappa 2022 年 8 月 17 日
I tried, it is not working
Star Strider
Star Strider 2022 年 8 月 17 日
I looked at your code, however I do not understand the part that you would need to change to get that result. I do not understand where you want to put that plot. It is straightforward to change a subplot series to a single call using hold.
Example —
x = linspace(0, 15);
y(1,:) = 10 - (x-5).^2;
y(2,:) = 15 - (x-7).^2;
figure
subplot(1,2,1)
plot(x, y(1,:))
grid
subplot(1,2,2)
plot(x, y(2,:))
grid
sgtitle('Using ''subplot''')
figure
plot(x, y(1,:))
hold on
plot(x, y(2,:))
hold off
grid
title('Using ''hold''')
.

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

カテゴリ

Help Center および File Exchange2-D and 3-D Plots についてさらに検索

タグ

製品


リリース

R2021b

Community Treasure Hunt

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

Start Hunting!

Translated by