How can I model conditionally defined exponential functions?
Show older comments
I am using the MatLab Curve Fitting Toolbox to model a conditionally defined exponential function. My function is that y = exp(g) from 0 to 3, exp(p) from 3 to 4, and exp(g) from 4 to 7 (and I import g and p in an Excel spreadsheet). So it looks like the following:
function y=f(g,p)
t=(0:1:7)';
y1=exp(g).*(0<=t & t<=3);
y2=exp(p).*(3<t & t<=4);
y3=exp(g).*(4<t & t<=7);
y=y1+y2+y3;
end
And I build the model as follows:
v = fit(t,f(g,p),'exp2');
But that gives me a fitted curve that doesn't take account of the fact that that exp(g) is 'turned off' from 3 to 4, and so I get a big outlier as in the attached image. Any advice?

Accepted Answer
More Answers (0)
Categories
Find more on Smoothing and Denoising in Help Center and File Exchange
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!