From: mahan on
I have a set of 10000 data points (x,y,z) with which the following system is created
B*c = 0

B1 = z.^2+x.^2;
B2= -2*z;
B3 = y.^2;
B4 = ones(length(x), 1);
B5 = x.*z;
B6 = y.*z;
B7 = x.*y;

where the unknown variables are c = [k1 k1*z0 k2 (k1*z0^2 - R) k3 k4 k5]'

The system is solved with

B = [B1 B2 B3 B4 B5 B6 B7];
[U,S,V] = svd(B,0);
solution = V(:,end);

I'd like to add one more constant so that we instead have the system

B1 = z.^2;
B2 = x.^2;
B3= -2*z;
B4 = y.^2;
B5 = ones(length(x), 1);
B6 = x.*z;
B7 = y.*z;
B8 = x.*y;

where c = [k1 k2 k1*z0 k3 (k1*z0^2 - R) k4 k5 k6]'

I try to solve it the same way as with the 7 unknown variables, but this does not work for the system with 8 unknowns. It seems that the system can not handle more than 7 variables. The solution isn't real. Is it possible to solve this problem?

Thanks in advance!
From: Greg Heath on
On Aug 9, 8:20 pm, "mahan " <maha...(a)hotmail.com> wrote:
> I have a set of 10000 data points (x,y,z) with which the following system is created
> B*c = 0
>
> B1 = z.^2+x.^2;
> B2= -2*z;
> B3 = y.^2;
> B4 = ones(length(x), 1);
> B5 = x.*z;
> B6 = y.*z;
> B7 = x.*y;
>
> where the unknown variables are c = [k1   k1*z0   k2   (k1*z0^2 - R)   k3   k4   k5]'
>
> The system is solved with
>
> B = [B1 B2 B3 B4 B5 B6 B7];
> [U,S,V] = svd(B,0);
> solution = V(:,end);
>
> I'd like to add one more constant so that we instead have the system
>
> B1 = z.^2;
> B2 = x.^2;
> B3= -2*z;
> B4 = y.^2;
> B5 = ones(length(x), 1);
> B6 = x.*z;
> B7 = y.*z;
> B8 = x.*y;
>
> where c = [k1   k2   k1*z0   k3   (k1*z0^2 - R)   k4   k5   k6]'
>
> I try to solve it the same way as with the 7 unknown variables, but this does not work for the system with 8 unknowns. It seems that the system can not handle more than 7 variables. The solution isn't real. Is it possible to solve this problem?

Please explain, in more detail, the phrases

"this does not work "

"The solution isn't real"

Greg
From: mahan on
Greg Heath <heath(a)alumni.brown.edu> wrote in message <bab4b454-aff5-4d8f-87f9-56ce2ce34789(a)v41g2000yqv.googlegroups.com>...
> On Aug 9, 8:20 pm, "mahan " <maha...(a)hotmail.com> wrote:
> > I have a set of 10000 data points (x,y,z) with which the following system is created
> > B*c = 0
> >
> > B1 = z.^2+x.^2;
> > B2= -2*z;
> > B3 = y.^2;
> > B4 = ones(length(x), 1);
> > B5 = x.*z;
> > B6 = y.*z;
> > B7 = x.*y;
> >
> > where the unknown variables are c = [k1   k1*z0   k2   (k1*z0^2 - R)   k3   k4   k5]'
> >
> > The system is solved with
> >
> > B = [B1 B2 B3 B4 B5 B6 B7];
> > [U,S,V] = svd(B,0);
> > solution = V(:,end);
> >
> > I'd like to add one more constant so that we instead have the system
> >
> > B1 = z.^2;
> > B2 = x.^2;
> > B3= -2*z;
> > B4 = y.^2;
> > B5 = ones(length(x), 1);
> > B6 = x.*z;
> > B7 = y.*z;
> > B8 = x.*y;
> >
> > where c = [k1   k2   k1*z0   k3   (k1*z0^2 - R)   k4   k5   k6]'
> >
> > I try to solve it the same way as with the 7 unknown variables, but this does not work for the system with 8 unknowns. It seems that the system can not handle more than 7 variables. The solution isn't real. Is it possible to solve this problem?
>
> Please explain, in more detail, the phrases
>
> "this does not work "
>
> "The solution isn't real"
>
> Greg

I'm trying to fit an ellipsoid to the data points. The solution with the seven unkown variables gives a good fit, but the other one does not. That one is not elliptic, as it should be. Instead it looks more like a big sphere, which is a really bad fit.

ellipsoid equation (8 unknowns) is
k1*(z-z0)^2 + k2*x^2 + k3*y^2 - R + k4*x*z + k5*y*z + k6*x*y= 0

ellipsoid equation (7 unknowns) is
k1*(z-z0)^2 + k1*x^2 + k3*y^2 - R + k4*x*z + k5*y*z + k6*x*y= 0
which gives a proper solution.
As you can see I want different coefficients for x^2 and (z-z0)^2.

Hope this helps, it's kind of hard to explain. I'd post a picture of the plot if I could...
From: Torsten Hennig on
> Greg Heath <heath(a)alumni.brown.edu> wrote in message
> <bab4b454-aff5-4d8f-87f9-56ce2ce34789(a)v41g2000yqv.goog
> legroups.com>...
> > On Aug 9, 8:20 pm, "mahan " <maha...(a)hotmail.com>
> wrote:
> > > I have a set of 10000 data points (x,y,z) with
> which the following system is created
> > > B*c = 0
> > >
> > > B1 = z.^2+x.^2;
> > > B2= -2*z;
> > > B3 = y.^2;
> > > B4 = ones(length(x), 1);
> > > B5 = x.*z;
> > > B6 = y.*z;
> > > B7 = x.*y;
> > >
> > > where the unknown variables are c = [k1   k1*z0  
> k2   (k1*z0^2 - R)   k3   k4   k5]'
> > >
> > > The system is solved with
> > >
> > > B = [B1 B2 B3 B4 B5 B6 B7];
> > > [U,S,V] = svd(B,0);
> > > solution = V(:,end);
> > >
> > > I'd like to add one more constant so that we
> instead have the system
> > >
> > > B1 = z.^2;
> > > B2 = x.^2;
> > > B3= -2*z;
> > > B4 = y.^2;
> > > B5 = ones(length(x), 1);
> > > B6 = x.*z;
> > > B7 = y.*z;
> > > B8 = x.*y;
> > >
> > > where c = [k1   k2   k1*z0   k3   (k1*z0^2 - R)  
> k4   k5   k6]'
> > >
> > > I try to solve it the same way as with the 7
> unknown variables, but this does not work for the
> system with 8 unknowns. It seems that the system can
> not handle more than 7 variables. The solution isn't
> real. Is it possible to solve this problem?
> >
> > Please explain, in more detail, the phrases
> >
> > "this does not work "
> >
> > "The solution isn't real"
> >
> > Greg
>
> I'm trying to fit an ellipsoid to the data points.
> The solution with the seven unkown variables gives a
> good fit, but the other one does not. That one is not
> elliptic, as it should be. Instead it looks more like
> a big sphere, which is a really bad fit.
>
> ellipsoid equation (8 unknowns) is
> k1*(z-z0)^2 + k2*x^2 + k3*y^2 - R + k4*x*z + k5*y*z +
> k6*x*y= 0
>
> ellipsoid equation (7 unknowns) is
> k1*(z-z0)^2 + k1*x^2 + k3*y^2 - R + k4*x*z + k5*y*z +
> k6*x*y= 0
> which gives a proper solution.
> As you can see I want different coefficients for x^2
> and (z-z0)^2.
>
> Hope this helps, it's kind of hard to explain. I'd
> post a picture of the plot if I could...

Normalize the equation by setting R=1.
Without the normalization, all the k_i are
only determined up to a multiplicative constant.

Best wishes
Torsten.