How to plot multiple lines in a graph?

643 ビュー (過去 30 日間)
zephyr21
zephyr21 2016 年 6 月 24 日
編集済み: DGM 2025 年 11 月 9 日
I have a matrix with several 5 layers. I want to plot the numbers at a specific gridpoint for layers 2,3, and 4. How would I go about doing this?
Thanks for the help!
  2 件のコメント
Stephen23
Stephen23 2016 年 6 月 25 日
編集済み: Stephen23 2016 年 6 月 25 日
@zephyr21: please upload your code here on this forum by editing your question and clicking the paperclip button. Make sure to include any data that is required to run the code.
DGM
DGM 2025 年 11 月 9 日
編集済み: DGM 2025 年 11 月 9 日
See plot()
Otherwise, I'd call this an unanswerably vague question.
There are already two answers for ways to plot multiple paired sets of x,y data, but x and y don't need to be vectors. They can be matrices, and there are multiple ways that they might be used. If or how that applied to the original problem is completely unknown. The documentation has examples.

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

回答 (3 件)

Muhammad Usman Saleem
Muhammad Usman Saleem 2016 年 6 月 24 日
x1=[2 3 4 5];
y1=[9 4 3 2];
x2=[11 20 30 50 ];
y2= [ 20 30 50 60];
plot(x1,y1)
hold on
plot(x2,y2)
hold off
This plot two line graphs on same plot

MathWorks Support Team
MathWorks Support Team 2019 年 5 月 22 日
Please see the following post, which has a good accepted answer to a similar question:

MAY THEE PHYU AUNG
MAY THEE PHYU AUNG 2025 年 11 月 8 日
x = linspace(0,10,100)
y = x.^2 .* exp(-x)
yd = 2*x .* exp(-x) - x.^2 .* exp(-x)
plot(x,y,'-o','LineWidth',2.2,'MarkerSize',7 ,x,yd,':s','LineWidth',2.2,'MarkerSize',7)

カテゴリ

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

Community Treasure Hunt

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

Start Hunting!

Translated by