简体   繁体   中英

Intersection between curve from points and a line

I'm new in matlab and I'm trying to find the intersection between a curve (from points) and a line.

I've some points and I've plot the interpolation between this points. Now I want to find the intersection between the interpolation (xi,yi) curve and another line.

x = [94.8;84.4;63.1;49.4;40.6;33.8;23.2;20.1;10.2;9.2;7.9];
y = [0; 11.4;29.7;41.6;47.5;50.1;52.9;50.6;32.2;28.1;0];
xi=94.8:-0.1:7.9;
yi=interp1(x,y,xi,'spline');
plot(x,y,'*');
hold on
plot(xi,yi);

I've researched but everything I've found needs a function. I already tried to convert the curve to a function using polyfit but the fit is not good enought.

It is posible to do this in matlab?

Thanks.

Basically, the error message ask you to input a function handle (similar to function pointer in other languages). It's not necessary to convert it into something that matches a mathematical definition of a function (eg polynom):

f=@(xi)(interp1(x,y,xi,'spline'))

This can be evaluated at every xi.

Usage like every other function:

f(1)
f(1:3)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM