How do I fit a piecewise continuous function?

4 views (last 30 days)
The following function is defined:
if true
% f = @(c, x_bsn) (c(1).*x_bsn.^(c(2))).*and(x_bsn>=bound2,x_bsn<=bound1)) + (c(3)-c(4).*x_bsn.^(c(5))).*(and(x_bsn>=bound3,x_bsn<bound2));
end
Where c(1)-c(5) are the coefficients that need to be determined, x_bsn is the variable and the boundaries are specified by bound1 - bound3.
Then a fit is done using:
if true
%fit = lsqcurvefit(f,c0,x,y);
end
Where x and y are the dataset.
The problem is that the two functions don't connect,i.e., Where the one function stops, the next one doesn't continue.
How do I create a continuous fit?
Any suggestions would be much appreciated, Amoré
p.s. Doing this part of my analysis in another program is unfortunately not an option.

Answers (0)

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!