How to find the crosspoint of two curve
3 ビュー (過去 30 日間)
古いコメントを表示
I have a array below,[-0.1227 0.0581 0.0733 -0.1087 -0.1375 0.1031 0.1839 -0.0309],now I use the function of 'spline' get the picture in attachment, How can I get the cross point of green line and the black line? The black line also is x_axis.
0 件のコメント
回答 (1 件)
kjetil87
2013 年 11 月 28 日
編集済み: kjetil87
2013 年 11 月 28 日
If i have done this correctly this should give you the first point in yy before each zero crossing.
y=[-0.1227 0.0581 0.0733 -0.1087 -0.1375 0.1031 0.1839 -0.0309];
x=1:numel(y);
xx=1:0.01:x(end);
yy=spline(x,y,xx);
preCrossIdx=find((yy(1:end-1)<0 & yy(2:end)>0) | (yy(1:end-1)>0 & yy(2:end)<0) );
figure;plot(yy,'x');hold on;plot(1:numel(yy),0,'black');
dummy=nan(size(yy));
dummy(preCrossIdx)=yy(preCrossIdx);
plot(dummy,'rx');
To figure out if the "next index of yy" is closer to zero ,you could just check which one has the closest abs value to zero. The exact crosspoint is a bit more tricky, but a smaller spacing in xx=1:spacing:numel(x) , will give a better approximation.
0 件のコメント
参考
カテゴリ
Help Center および File Exchange で Spline Postprocessing についてさらに検索
製品
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!