How to find the crosspoint of two curve
3 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
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 comentarios
Respuestas (1)
kjetil87
el 28 de Nov. de 2013
Editada: kjetil87
el 28 de Nov. de 2013
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 comentarios
Ver también
Categorías
Más información sobre Spline Postprocessing en Help Center y File Exchange.
Productos
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!