File Exchange

image thumbnail

Find Polynomial Intersections

version 1.0 (4.7 KB) by

Find the intersections between 2 or more polynomials.



View License

Given the coefficients of 2 or more polynomials, this program will return their intersection points be it real or imaginary and the full string representation of these polynomial equations. e.g. 'y=2*x^3+4*x^2+3'
Suitable for use with the MATLAB 'polyfit' function

Comments and Ratings (7)

Alex Wyatt

Alex Wyatt

This is nice, I used it first time and it worked.


Edward (view profile)

I can't get this code to work, I have solve() but I get an error even when using the supplied test function:

Randomly generating coefficient values based on constraints
5 -3
Solve the two polynomials using "solve_polynomials"
??? Error using ==> str2num at 33
Requires string or character array input.

Error in ==> solve_polynomials at 115
intersection_coords = [intersection_coords; str2num(X(n).s),str2num(Y(n).s)];

Error in ==> test_solve_polynomials at 99
[intersection,real_intersection,complex_intersection,polystr] = ...

It would help me out a lot if it worked tho!



Andrea Johnson

Acutally, solve is part of the symbolic math toolbox which is not part of the core matlab package, I am unable to use this function as well...the alternate solution suggested would work for the intersection of two vectors (as would the function intersect), but not a poly structure, which just consists of the coefficients

Alister Fong

For your information, 'solve' is a built-in matlab function. Please check the matlab documentations.

Duane Hanselman

this function calls an unknown function named "solve", which renders this function unusable.
This function creates a string representation of the input polynomial row vectors.

For two polys can't this function be replaced by:

function x=polyintersect(p1,p2)
p=[zeros(1,np2-np1) p1]-[zeros(1,np1-np2) p2]; % find polynomial difference
x=roots(p); % zeros of difference are intersections????

MATLAB Release
MATLAB 6.0 (R12)

Download apps, toolboxes, and other File Exchange content using Add-On Explorer in MATLAB.

» Watch video