Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

Thread Subject:
Quadric approximation and

Subject: Quadric approximation and

From: Alexander Petrov

Date: 22 Jul, 2010 16:17:06

Message: 1 of 6

Hello,

Application of Matlab fit function under 2d-matrix give me an quadratic function:
 sf(x,y) = p00 + p10*x + p01*y + p20*x^2 + p11*x*y + p02*y^2

But what I want is an general equation of quadric surface, like on that webpage - http://mathworld.wolfram.com/QuadraticSurface.html

I've know, that this is a stupid question, but could I really rewrite matlab result as:

let z= sf(x,y);
 p00 + p10*x + p01*y + p20*x^2 + p11*x*y + p02*y^2 - z = 0

Does such a "trick" give me an general equation of quadric surface ?

Thank you

Subject: Quadric approximation and

From: Roger Stafford

Date: 22 Jul, 2010 16:33:06

Message: 2 of 6

"Alexander Petrov" <vwvw@yandex.ru> wrote in message <i29qu2$g1$1@fred.mathworks.com>...
> Hello,
>
> Application of Matlab fit function under 2d-matrix give me an quadratic function:
> sf(x,y) = p00 + p10*x + p01*y + p20*x^2 + p11*x*y + p02*y^2
>
> But what I want is an general equation of quadric surface, like on that webpage - http://mathworld.wolfram.com/QuadraticSurface.html
>
> I've know, that this is a stupid question, but could I really rewrite matlab result as:
>
> let z= sf(x,y);
> p00 + p10*x + p01*y + p20*x^2 + p11*x*y + p02*y^2 - z = 0
>
> Does such a "trick" give me an general equation of quadric surface ?
>
> Thank you
- - - - - - - -
  The answer is no. Try solving for z in the quadratic surface equation you referred to and you will get an expression involving x and y within square roots, which is incompatible with your sf(x, y).

Roger Stafford

Subject: Quadric approximation and

From: Walter Roberson

Date: 22 Jul, 2010 16:34:49

Message: 3 of 6

Alexander Petrov wrote:

> Application of Matlab fit function under 2d-matrix give me an quadratic
> function: sf(x,y) = p00 + p10*x + p01*y + p20*x^2 + p11*x*y + p02*y^2
>
> But what I want is an general equation of quadric surface, like on that
> webpage - http://mathworld.wolfram.com/QuadraticSurface.html
>
> I've know, that this is a stupid question, but could I really rewrite
> matlab result as:
>
> let z= sf(x,y);
> p00 + p10*x + p01*y + p20*x^2 + p11*x*y + p02*y^2 - z = 0
>
> Does such a "trick" give me an general equation of quadric surface ?

No. If z = sf(x,y) and the overall surface is to remain quadradic, then
sf(x,y) would have to be a multinomial in x and y in which the "total power"
of each term did not exceed 2. Such a multinomial, when substituted into the
proposed expression, would be of identical form to the p00 <etc> expression
except with different coefficients. This would not be sufficient to express
the general quadratic surfaces as described on Wolfram's page, which require
polynomials in x, y, and z.

Subject: Quadric approximation and

From: Alexander Petrov

Date: 22 Jul, 2010 20:14:04

Message: 4 of 6

"Roger Stafford" <ellieandrogerxyzzy@mindspring.com.invalid> wrote in message
> The answer is no. Try solving for z in the quadratic surface equation you referred to and you will get an expression involving x and y within square roots, which is incompatible with your sf(x, y).

Thank you for your answer. And if I understand you properly - to get the model in form of general equation of quadric surface from my data (fitting model form of general equation to data) I should or, as you told me, solving for z in the quadratic surface equation (that looks not very simple) or use another method of approximation (not use "fit" matlab function), that has explicitly notion about the form of model I needed ? Am I right ?

In fact after getting model in form of quadric surface (Quadratic form), I want to reduce it to canonical form - and all methods of reduction, that I found, work with general equation of quadric surface.

Thank you

Subject: Quadric approximation and

From: Walter Roberson

Date: 22 Jul, 2010 21:58:43

Message: 5 of 6

Alexander Petrov wrote:
> "Roger Stafford" <ellieandrogerxyzzy@mindspring.com.invalid> wrote in
> message
>> The answer is no. Try solving for z in the quadratic surface
>> equation you referred to and you will get an expression involving x
>> and y within square roots, which is incompatible with your sf(x, y).
>
> Thank you for your answer. And if I understand you properly - to get the
> model in form of general equation of quadric surface from my data
> (fitting model form of general equation to data) I should or, as you
> told me, solving for z in the quadratic surface equation (that looks not
> very simple) or use another method of approximation (not use "fit"
> matlab function), that has explicitly notion about the form of model I
> needed ? Am I right ?
>
> In fact after getting model in form of quadric surface (Quadratic form),
> I want to reduce it to canonical form - and all methods of reduction,
> that I found, work with general equation of quadric surface.

I am having difficulty following what you are trying to do.

What do you have as input data?

What are you trying to do with the data?

Is the approach of finding the quadratic surface a particular method to reach
your ultimate goal, or do you specifically want to use this approach?


I tried going back to see if you had described your situation in some previous
posting, but it does not appear that you had posted before your initial
quadratic surface message.

Subject: Quadric approximation and

From: Roger Stafford

Date: 22 Jul, 2010 22:48:04

Message: 6 of 6

"Alexander Petrov" <vwvw@yandex.ru> wrote in message <i29qu2$g1$1@fred.mathworks.com>...
> Hello,
>
> Application of Matlab fit function under 2d-matrix give me an quadratic function:
> sf(x,y) = p00 + p10*x + p01*y + p20*x^2 + p11*x*y + p02*y^2
>
> But what I want is an general equation of quadric surface, like on that webpage - http://mathworld.wolfram.com/QuadraticSurface.html
> .......
- - - - - - - - - -
  If you have reason to believe that your data does fit some quadratic surface reasonably well, you can try the following to find a least squares approximate fit. We can use the notation that was contained in the Mathworld website you referred to. Suppose your data is in the form of three column vectors, X, Y, and Z of length n. Do this:

 A = [X.^2,Y.^2,Z.^2,2*Y.*Z,2*Z.*X,2*X.*Y,X,Y,Z,ones(n,1];
 [U,S,V] = svd(A,0);

Then the eigenvector in column 10 of V would be the ten coefficients, [a;b;c;f;g;h;p;q;r;d], giving a least squares fit to the given data. This is least squares in the sense that the sum of the quantities
 
 (a*x^2+b*y^2+c*z^2+2*f*y*z+2*g*z*x+2*h*x*y+p*x+q*y+r*z+d)^2

for all data points is minimized, given that

 a^2+b^2+c^2+f^2+g^2+h^2+p^2+q^2+r^2+d^2 = 1

The eigenvalue in S(10,10) is the square root of the value of this least sum of squares, so if it is small compared with the sqrt(n), then the fit is good.

  As indicated in that Mathworld article, part of finding the canonical form for the surface is finding the necessary rotation with

 B = [a,h,g;
      h,b,f;
      g,f,c]
 [R,D] = eig(B);

where the R matrix provides the necessary rotation.

Roger Stafford

Tags for this Thread

No tags are associated with this thread.

What are tags?

A tag is like a keyword or category label associated with each thread. Tags make it easier for you to find threads of interest.

Anyone can tag a thread. Tags are public and visible to everyone.

Contact us