Got Questions? Get Answers.
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:
Applying lsqcurvefit to a function f(x,T)

Subject: Applying lsqcurvefit to a function f(x,T)

From: Lars

Date: 3 Aug, 2012 13:22:09

Message: 1 of 3

Hi,
I am really a rookie in both data analysis as well as Matlab optimization toolbox.
In order to adopt measured data to model which want to use in Simulink I have to run a nonlinear regression analysis.
The function model is like this:
y(x,T)=1.2+(a(1)+a(2)*T)/0.02*x+a(3)*log10((a(4)+a(5)/T+a(6)/T.^2)/0.02*x+1)
So the function is dependent on x and T.
You can also say that a(1) and a(2) are a function of T (=a(1)+a(2)*T).
The same is true for a(4), a(5) and a(6) (=a(4)+a(5)/T+a(6)/T^2).

So, is it possible to feed the lsqcurvefit with "two" x variables?

Cheers,

Subject: Applying lsqcurvefit to a function f(x,T)

From: Marc

Date: 3 Aug, 2012 13:41:24

Message: 2 of 3

"Lars" wrote in message <jvgja1$n68$1@newscl01ah.mathworks.com>...
> Hi,
> I am really a rookie in both data analysis as well as Matlab optimization toolbox.
> In order to adopt measured data to model which want to use in Simulink I have to run a nonlinear regression analysis.
> The function model is like this:
> y(x,T)=1.2+(a(1)+a(2)*T)/0.02*x+a(3)*log10((a(4)+a(5)/T+a(6)/T.^2)/0.02*x+1)
> So the function is dependent on x and T.
> You can also say that a(1) and a(2) are a function of T (=a(1)+a(2)*T).
> The same is true for a(4), a(5) and a(6) (=a(4)+a(5)/T+a(6)/T^2).
>
> So, is it possible to feed the lsqcurvefit with "two" x variables?
>
> Cheers,

I believe this is possible. See the example for nlinfit in the stats toolbox for 'hougen.m' example under nonlinear regression.

nlinfit, lsqnonlin and lscurvefit all use similar solver engines so I typically find them interchangeable for the most part.

In the example for hougen.m, one of the key points that I always screw up on is making sure your function spits out a column vector for f(x) where in your case x1 is x and x2 is T.

Hope this helps

Subject: Applying lsqcurvefit to a function f(x,T)

From: Lars

Date: 3 Aug, 2012 17:52:11

Message: 3 of 3

"Marc" wrote in message <jvgke4$s3o$1@newscl01ah.mathworks.com>...
> "Lars" wrote in message <jvgja1$n68$1@newscl01ah.mathworks.com>...
> > Hi,
> > I am really a rookie in both data analysis as well as Matlab optimization toolbox.
> > In order to adopt measured data to model which want to use in Simulink I have to run a nonlinear regression analysis.
> > The function model is like this:
> > y(x,T)=1.2+(a(1)+a(2)*T)/0.02*x+a(3)*log10((a(4)+a(5)/T+a(6)/T.^2)/0.02*x+1)
> > So the function is dependent on x and T.
> > You can also say that a(1) and a(2) are a function of T (=a(1)+a(2)*T).
> > The same is true for a(4), a(5) and a(6) (=a(4)+a(5)/T+a(6)/T^2).
> >
> > So, is it possible to feed the lsqcurvefit with "two" x variables?
> >
> > Cheers,
>
> I believe this is possible. See the example for nlinfit in the stats toolbox for 'hougen.m' example under nonlinear regression.
>
> nlinfit, lsqnonlin and lscurvefit all use similar solver engines so I typically find them interchangeable for the most part.
>
> In the example for hougen.m, one of the key points that I always screw up on is making sure your function spits out a column vector for f(x) where in your case x1 is x and x2 is T.
>
> Hope this helps

Well, yes! That solved this problem! Cheers!

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