plotting two-vectors on same axis
1 回表示 (過去 30 日間)
古いコメントを表示
Raghavendra Reddy P
2015 年 6 月 1 日
コメント済み: Raghavendra Reddy P
2015 年 6 月 1 日
I have vector x contains 33-elements
x = [
1.0000
0.9974
0.9853
0.9793
0.9735
0.9588
0.9560
0.9461
0.9421
0.9385
0.9380
0.9372
0.9343
0.9333
0.9319
0.9306
0.9286
0.9280
0.9969
0.9933
0.9926
0.9920
0.9817
0.9751
0.9718
0.9572
0.9552
0.9462
0.9397
0.9362
0.9321
0.9291
0.9288]
>> t=[1:33];
>> plot(t,x)
gives you a graph, now i have a y vector which contains only 13 elements
y = [
1.0000
0.9974
0.9853
0.9712
0.9588
0.9360
0.9333
0.9295
0.9928
0.9763
0.9483
0.9397
0.9279]
now i wanted to draw graph on existing one such that elements values of y, which are near to x values should come same t-axis points. example:- y(4)=0.9712 is almost equal equal to x(5)=0.9735 at t=5, y(end)=0.9279 is equal to x(end)=0.9288 at t=33... hence i want y(4),y(end) on t=5,t=33.
0 件のコメント
採用された回答
Walter Roberson
2015 年 6 月 1 日
y(end)=0.9279 is equal to x(end)=0.9288 at t=33
0.9729 is smaller than any x value, and is closest to x(18) which is 0.9280.
y(4)=0.9712 is almost equal equal to x(5)=0.9735 at t=5
0.9712 is closer to x(25) = 0.9718
The descriptive part about "near to x values" leads to this code:
plot(1:length(x),x,'r',interp1(x, 1:length(x), y, 'nearest', 'extrap'),y,'g.-')
which has each y value being drawn at the t value that corresponds to the x value that is closest to the y value.
Your rules about what is near enough do not appear to be well defined.
その他の回答 (0 件)
参考
カテゴリ
Help Center および File Exchange で Discrete Data Plots についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!