Fitting two data sets

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

• 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

• 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?