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:
two variable curve fit

Subject: two variable curve fit

From: Yi

Date: 20 Mar, 2012 02:32:16

Message: 1 of 3

Hi I have many data and want to do a two variable curve fit, and according to other literature, the curve should be quartic

x = [x1, x2, x3, ...., x100]
y = [y1, y2, y3, ..., y100]
z = [z1, z2, z3, ..., z100]

x1, x2..., x100, y1, y2, ... y100, z1, z2,...z100 has real values.

I want to get a curve:
z = a0 + a1*x + a2*x^2 + a3* y + a4*y^2 +a5*x*y

How could I get a0, a1, a2, a3, a4 and a5.

I guess least square method should work, but I don't know if matlab has any existing command I could call.

Thanks a lot

Subject: two variable curve fit

From: John D'Errico

Date: 20 Mar, 2012 02:44:23

Message: 2 of 3

"Yi " <hvachy@163.com> wrote in message <jk8q7g$h4h$1@newscl01ah.mathworks.com>...
> Hi I have many data and want to do a two variable curve fit, and according to other literature, the curve should be quartic
>
> x = [x1, x2, x3, ...., x100]
> y = [y1, y2, y3, ..., y100]
> z = [z1, z2, z3, ..., z100]
>
> x1, x2..., x100, y1, y2, ... y100, z1, z2,...z100 has real values.
>
> I want to get a curve:
> z = a0 + a1*x + a2*x^2 + a3* y + a4*y^2 +a5*x*y
>
> How could I get a0, a1, a2, a3, a4 and a5.
>
> I guess least square method should work, but I don't know if matlab has any existing command I could call.
>
> Thanks a lot

http://www.mathworks.com/matlabcentral/fileexchange/34765-polyfitn

Subject: two variable curve fit

From: Steven_Lord

Date: 20 Mar, 2012 13:40:05

Message: 3 of 3



"Yi " <hvachy@163.com> wrote in message
news:jk8q7g$h4h$1@newscl01ah.mathworks.com...
> Hi I have many data and want to do a two variable curve fit, and according
> to other literature, the curve should be quartic
> x = [x1, x2, x3, ...., x100]
> y = [y1, y2, y3, ..., y100]
> z = [z1, z2, z3, ..., z100]
>
> x1, x2..., x100, y1, y2, ... y100, z1, z2,...z100 has real values.
> I want to get a curve: z = a0 + a1*x + a2*x^2 + a3* y + a4*y^2 +a5*x*y
>
> How could I get a0, a1, a2, a3, a4 and a5.
>
> I guess least square method should work, but I don't know if matlab has
> any existing command I could call.

Use backslash.

http://www.mathworks.com/help/techdoc/data_analysis/f1-8450.html

Combine the techniques from the second and third section on that page.

--
Steve Lord
slord@mathworks.com
To contact Technical Support use the Contact Us link on
http://www.mathworks.com

Tags for 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