How can I model conditionally defined exponential functions?
显示 更早的评论
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?

采纳的回答
更多回答(0 个)
类别
在 帮助中心 和 File Exchange 中查找有关 Smoothing and Denoising 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!
