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
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
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!
cheers
ed
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)
np1=length(p1);
np2=length(p2);
p=[zeros(1,np2-np1) p1]-[zeros(1,np1-np2) p2]; % find polynomial difference
x=roots(p); % zeros of difference are intersections????