Intersection of two curves
77 次查看(过去 30 天)
显示 更早的评论
Hi,
I am trying to find the intersection point of two curves of different functions plotted in a same graph. Can someone help me to find the [x] value of the intersection point.
Thanks
N = [1 2 3 4 5 6]
P = [1.48982012272225e-09 1.20413388047633e-08 4.17435214011468e-08 1.03854604485768e-07 2.17722472607192e-07 4.11611145129198e-07]
f = [1254.80279734744 316.932254638916 144.685314017159 85.4215488617609 58.6806449463084 44.5833312773839]
The script is,
figure
yyaxis left
plot(N,Pi_I)
yyaxis right
plot(N,f)
1 个评论
Star Strider
2022-8-14
The curves do not intersect in the region-of-interest (defined by the ‘N’ vector).
It may be possible to force an intersection by extrapolating both of them, however I would not trust that result because you have no idea what the curves do outside the known values. They might never intersect, or they could have an infinite number of intersections if one or both are oscillatory and have appropriate magnitudes.
采纳的回答
Bruno Luong
2022-8-14
编辑:Torsten
2022-8-14
Intersection of to things that are not comparable? why not? just avoid using it to conclude anything that matters.
N = [1 2 3 4 5 6]
P = [1.48982012272225e-09 1.20413388047633e-08 4.17435214011468e-08 1.03854604485768e-07 2.17722472607192e-07 4.11611145129198e-07]
f = [1254.80279734744 316.932254638916 144.685314017159 85.4215488617609 58.6806449463084 44.5833312773839]
figure
yyaxis left
plot(N,P)
yyaxis right
plot(N,f)
yyaxis right
ylimr = ylim;
yyaxis left
yliml = ylim;
Ps = (P-yliml(1))./diff(yliml);
fs = (f-ylimr(1))./diff(ylimr);
ds = Ps-fs;
i=find(ds(1:end-1).*ds(2:end)<0,1);
Nx = interp1(ds(i:i+1),N(i:i+1),0);
yyaxis left
hold on
plot(Nx,interp1(N,P,Nx),'ob')
yyaxis right
hold on
plot(Nx,interp1(N,f,Nx),'xr')
更多回答(2 个)
Torsten
2022-8-14
Do you see a point of intersection ? I don't.
N = [1 2 3 4 5 6];
P = [1.48982012272225e-09 1.20413388047633e-08 4.17435214011468e-08 1.03854604485768e-07 2.17722472607192e-07 4.11611145129198e-07];
f = [1254.80279734744 316.932254638916 144.685314017159 85.4215488617609 58.6806449463084 44.5833312773839];
plot(N,P)
hold on
plot(N,f)
2 个评论
Torsten
2022-8-14
Don't you see the different scales of the axes ?
The curves don't intersect (at least not within the region where data are available), as can be seen in the "real" plot above.
dpb
2022-8-14
One approach might be something like
R_PF=mean(P./f); % the average scaling between the two
fn1=@(x)interp1(N,f*R_PF,x); % interpolate the scaled values
fn2=@(x)interp1(N,P,x); % and the other
fnD=@(x)fn2(x)-fn1(x); % evaluate the difference between the two, for
x=interp1(fnD(N),N,0); % finding the zero point reverse lookup/interpolation for "X"
The above produces
>> x
x =
4.5738
>> fnD(x)
ans =
5.2940e-23
>>
另请参阅
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!