How to plot multiple data sets in the same graph for a common range?
古いコメントを表示
I have two sets of data for two curves. The first set is
x_Exp = [1.1;1.083;1.08;1.073;1.015;0.993;0.987;0.978;0.974;0.946;0.941;0.897];
y_Exp = [5.504201829;5.639866885;5.610055654;5.789536433;5.694270035;5.525332713;5.634467851;5.540490674;5.585972432;5.111549463;5.129729547;4.542420443];
The second set is
x_Model = [1.11111;1.05263;1;0.952381;0.909091;0.869565];
y_Model = [5.317717952;5.632039396;5.896917576;5.622196354;5.107126594;4.5305684];
How can i plot them in the same graph for a common range?
That means i need to find the the x_Model values which are smaller then x_Exp and then the corresponding y_Model values. It is easy to find the x_Model values that are smaller then x_Exp but how to find the corresponding values? How can i find those values so that i can plot them?
採用された回答
その他の回答 (1 件)
madhan ravi
2018 年 11 月 6 日
x_Exp = [1.1;1.083;1.08;1.073;1.015;0.993;0.987;0.978;0.974;0.946;0.941;0.897];
y_Exp = [5.504201829;5.639866885;5.610055654;5.789536433;5.694270035;5.525332713;5.634467851;5.540490674;5.585972432;5.111549463;5.129729547;4.542420443];
x_Model = [1.11111;1.05263;1;0.952381;0.909091;0.869565];
y_Model = [5.317717952;5.632039396;5.896917576;5.622196354;5.107126594;4.5305684];
idx = any(x_Model) < x_Exp
plot(x_Model(idx),y_Model(idx),'-*c')
9 件のコメント
madhan ravi
2018 年 11 月 6 日
編集済み: madhan ravi
2018 年 11 月 6 日
by logical indexing you can get desired values and plot use
hold on
after the first plot command in order to plot multiple graphs
Mr. 206
2018 年 11 月 6 日
madhan ravi
2018 年 11 月 6 日
so what should be the desired x_Model ?
Mr. 206
2018 年 11 月 6 日
madhan ravi
2018 年 11 月 6 日
I know what you mean but write those
x_Model values are smaller or equal to x_Exp
values explicitly so that I can code it according to the requirement
Mr. 206
2018 年 11 月 6 日
madhan ravi
2018 年 11 月 6 日
give me sometime to figure it out
Mr. 206
2018 年 11 月 6 日
madhan ravi
2018 年 11 月 6 日
Anytime :) , If you would have added this comment before I would have given the answer straight away
カテゴリ
ヘルプ センター および File Exchange で Line Plots についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!
