フィルターのクリア

can anyone tell me how to plot a three curves with different x and y values for all curve in single plot?

2 ビュー (過去 30 日間)
Multiplot curve

採用された回答

KSSV
KSSV 2018 年 9 月 20 日
Read about hold on
figure
hold on
plot(..)
plot(...)

その他の回答 (2 件)

ANKUR KUMAR
ANKUR KUMAR 2018 年 9 月 20 日
編集済み: ANKUR KUMAR 2018 年 9 月 20 日
As you have not given any specific data set. I am taking a random data to give you an example.
Example 1
Just plot all three lines subsequently.
col={'r','b','k'}
for kk=1:3
aa=spline((0:15),randi(10,1,16),(0:0.1:15))
x=randi(100,1,1);
plot((x:0.1:x+15),aa,col{kk})
hold on
end
legend({'Line 1','Line 2','Line 3'})
Don't worry if you don't understand the third and fourth line. It's just the random data.
Example 2
If you want to skip using the loop, you can plot using cellfun too. The following loop is just to create the random data set. If you have the dataset, just put them in a cell.
col={'r','b','k'}
for kk=1:3
YY{kk}=spline((0:15),randi(10,1,16),(0:0.1:15))
x=randi(10,1,1);
XX{kk}=(x:0.1:x+15);
end
hold on
cellfun(@(x,y,z) plot(x,y,z),XX,YY,col,'uni',0)
legend({'Line 1','Line 2','Line 3'})
  4 件のコメント
Sathyamoorthy R
Sathyamoorthy R 2018 年 9 月 20 日
I am getting the following error
Error using linspace Too many input arguments
ANKUR KUMAR
ANKUR KUMAR 2018 年 9 月 20 日
Cross check you prog. I have run twice the above prog.

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


KALYAN ACHARJYA
KALYAN ACHARJYA 2018 年 9 月 20 日
Check here, It may be helpful.
Also check here

カテゴリ

Help Center および File ExchangeScatter Plots についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by