#### Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

#### Categories

Welcome to the new platform of Programmers Heaven! We apologize for the inconvenience caused, if you visited us from a broken link of the previous version. The main reason to move to a new platform is to provide more effective and collaborative experience to you all. Please feel free to experience the new platform and use it's exciting features. Contact us for any issue that you need to get clarified. We are more than happy to help you.

# Fitting two data sets

Posts: 2Member
I have too sets of data. I want to fit with the expressions

y=a*log(x/b) and y=c*log(x/b)

Is there any way to fit both expressions simultaneously to obtain b?

msc05
· ·

• Posts: 41Member
Yes, it's possible but not trivial.

You may use optimization techniques (at least).
If you know a and c, then you may use use fminbnd to
find b.

If you want to find a, b and c, then you may use
fminsearch, or other functions within the
Optimization Toolbox. I like fminbnd and fminsearch
because they're standard functions.

You have to define an "objective function". You have
to prepare it in such a way, that its minimum value
becomes your solution. Its minimum value is going to
be found by fminbnd (finds only one variable) or
fminsearch (finds more than one variable).

It's possible but not trivial...

Here are two nice examples of curve fitting:
http://www.matrixlab-examples.com/nonlinear-programming.html
http://www.matrixlab-examples.com/exponential-regression.html

· ·
• Posts: 2Member
I think I have found another way out of the problem. My plan is to translat one of the data sets along the x-axis and then fit by the expression

y=a*log(x/b) for x=[0;1000], y=c*log(x/b) for x=[1000;inf]

How do I write such an expression in Matlab?
· ·