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
This is nice, I used it first time and it worked.
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
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!
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
For your information, 'solve' is a built-in matlab function. Please check the matlab documentations.
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:
p=[zeros(1,np2-np1) p1]-[zeros(1,np1-np2) p2]; % find polynomial difference
x=roots(p); % zeros of difference are intersections????