# System of equations { parametic & using 5 polynomial solve } not working

1 view (last 30 days)
Suzie Oman on 30 Jan 2018
Commented: John D'Errico on 30 Jan 2018
My system of equations is yielding inaccurate results. Where N is a 400 x 3 matrix (x,y,z points) and P0 and P1 are points on a line we are trying to find the line - surface intersect for.
sS = size(N);
if sS(1) < sS(2)
N = N';
end
X = N(:,1);
Y = N(:,2);
Z = N(:,3);
[s,gof] = fit([X, Y],Z,'poly55');
s1(1) = s.p00;
s1(2) = s.p10;
s1(3) = s.p01;
s1(4) = s.p20;
s1(5) = s.p11;
s1(6) = s.p02;
s1(7) = s.p30;
s1(8) = s.p21;
s1(9) = s.p12;
s1(10) = s.p03;
s1(11) = s.p40;
s1(12) = s.p31;
s1(13) = s.p22;
s1(14) = s.p04;
s1(15) = s.p50;
s1(16) = s.p41;
s1(17) = s.p32;
s1(18) = s.p23;
s1(19) = s.p14;
s1(20) = s.p13;
s1(21) = s.p05;
p00 = s1(1);
p10 = s1(2);
p01 = s1(3);
p20 = s1(4);
p11 = s1(5);
p02 = s1(6);
p30 = s1(7);
p21 = s1(8);
p12 = s1(9);
p03 = s1(10);
p40 = s1(11);
p31 = s1(12);
p22 = s1(13);
p04 = s1(14);
p50 = s1(15);
p41 = s1(16);
p32 = s1(17);
p23 = s1(18);
p14 = s1(19);
p13 = s1(20);
p05 = s1(21);
clear x y z t
syms x y z t
eq1 = z == p00 + p10*x + p01*y + p20*x.^2 + p11*x.*y + p02*y.^2 + p30*x.^3 + p21*x.^2*y + p12*x.*y.^2 +p03*y.^3 +p40*x.^4 +p31*x.^3*y+ p22*x.^2*y.^2 + p13*x.*y.^3 + p04*y.^4 + p50*x.^5 + p41*x.^4*y + p32*x.^3*y.^2 + p23*x.^2*y.^3 + p14*x.*y.^4 + p05*y.^5;
v = -1*p2 + p1 ;
po = p1;
eq2 = x == po(1) + v(1)*t;
eq3 = y == po(2) + v(2)*t;
eq4 = z == po(3) + v(3)*t;
[x, y, z, t] = solve([eq1,eq2,eq3,eq4],[x,y,z,t]);
John D'Errico on 30 Jan 2018
I have a good reason for asking to see the data, as well as the polynomial, because I think that polynomial is very likely totally inappropriate to be fit here. And while that is only a guess, I think it to be a good one.
I don't think you can offer enough to get me interested in a consulting contract either. Anyway, Answers is not a place where you post a request for someone to perform private consulting, so advertising as if it is a bulletin board.
So I'd suggest that you contact your local university stats department, and find someone willing to work on your terms, IF you can.
Your question is virtually impossible to answer as it is though, without seeing your data. That is especially true since I'll bet I know what you are doing, and why I think there is a problem in the fit.

Suzie Oman on 30 Jan 2018
Thanks. I will follow-up this evening with a subset of the data. That should be fine. I apologize. Just trying to do the right thing.
Best, Rosie
John D'Errico on 30 Jan 2018
If you can do that, fine. I think we can help then.

### Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!