Dear MATLAB users,
I am stuck on a problem I am working with, and I really hope you guys/gals can help me.
Suppose I have two different sets of 3D point data:
Data1 = rand(100,3) .* [100 100 10];
Data2 = rand(100,3) .* [100 10 100];
figure; hold on; axis equal;
plot3(Data1(:,1),Data1(:,2),Data1(:,3),'.')
plot3(Data2(:,1),Data2(:,2),Data2(:,3),'.')
Now suppose I want to fit a plane through my first dataset:
SurfFit = fit([Data1(:,1),Data1(:,2)], Data1(:,3),'poly11');
This goes according to plan. I can see that MATLAB fits a plane (Poly11: Z = p00 + p10*x + p01*y) through my data. I can see that for the three coefficients it gets certain values:
Linear model Poly11:
val(x,y) = p00 + p10*x + p01*y
Coefficients (with 95
p00 = 6.429 (4.915, 7.943)
p10 = -0.01357 (-0.03247, 0.005329)
p01 = -0.005913 (-0.02611, 0.01429)
Obviously, due to randomness, your values might be different..
Now, I want to fit a surface (poly11) through my second dataset, but it should be orthogonal to my first plane. This means that the following statement must be met:
p00(1)*p00(2) + p10(1)*p10(2) + p01(1)*p01(2) = 0
Where (1) refers to the first surface, and (2) to the second surface.
At this point I don't know how to proceed, since I am not that familiar with surface fitting. I know that you can make your own custom equations to fit a surface on, but I do not know how to combine the Poly11 surface with the above equation to make it fit my data. Is it even possible at all? Any help would be appreciated!
Kind regards,
Mark