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
0 件のコメント
採用された回答
その他の回答 (2 件)
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 件のコメント
参考
カテゴリ
Help Center および File Exchange で Scatter Plots についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!