2010/5/14
<address@hidden>
Hello!
I have two sets of measured points (in 3D). Points of each set are supposed to
sit on a plane.
Now I want to find the intersection line and its directional and positional
error.
The best fitting plane could be found with linear regression. The plane is in vector 'B', errors etc can be found in variables 'Residuals' and 'STATS'
octave:1> % generate some X
octave:1> X=rand(20,2);
octave:2> % put points near a plane
octave:2> y=.1*X(:,1)-.2*X(:,2) + (.2*rand(20,1)-.1) + 5 ;
octave:3> % add column of ones to find the constant
octave:3> X = [X ones(rows(X),1)] ;
octave:4> % find plane with linear regression
octave:4> [B, BINT, Residuals, RINT, STATS] = regress (y,X);
octave:5> B
B =
0.099276
-0.194231
5.009262
octave:6> % I like visual :-)
octave:6> [xx,yy] = meshgrid([0:.1:1],[0:.1:1]);
octave:7> zz = B(1)*xx+B(2)*yy+B(3);
octave:8> mesh(xx,yy,zz);
octave:9> hold on
octave:10> plot3(X(:,1),X(:,2),y,"o");