Code covered by the BSD License  

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

» Watch video

Highlights from
Find Polynomial Intersections

3.0 | 3 ratings Rate this file 12 Downloads (last 30 days) File Size: 4.7 KB File ID: #4297 Version: 1.0

Find Polynomial Intersections


Alister Fong (view profile)


19 Dec 2003 (Updated )

Find the intersections between 2 or more polynomials.

| Watch this File

File Information

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

MATLAB release MATLAB 6.0 (R12)
Tags for This File   Please login to tag files.
Please login to add a comment or rating.
Comments and Ratings (5)
08 Sep 2011 Lufuno Vhengani

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

02 Jul 2009 Edward

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!



Comment only
07 May 2004 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

11 Feb 2004 Alister Fong

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

Comment only
07 Feb 2004 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????

Contact us