How do i make an exponential curve graph from a vector?
3 次查看(过去 30 天)
显示 更早的评论
How do i make a graph that looks like this from the following code
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/1556794/image.png)
I tried fitnlm or polyval or polyfit but i don't know if i'm not using the right functions or i just don't understand how to use them.
Teta1 = [0 19.727 25.705 28.796 30.154 31.375 31.787 31.961 31.164 32.504 32.285];
Teta2 = [0 11.356 17.764 21.162 22.806 23.712 24.292 24.573 24.765 24.826 24.753];
Teta3 = [0 10.239 15.604 18.588 20.312 21.164 21.579 21.671 21.896 21.820 21.750];
Teta4 = [0 20.346 28.186 32.687 35.272 26.975 37.823 38.785 38.794 39.194 39.240];
Teta5 = [0 11.957 20.023 24.820 27.567 29.355 30.386 31.244 31.458 31.830 31.772];
Teta6 = [0 10.803 17.642 22.031 24.655 26.389 27.414 27.884 28.064 28.299 28.152];
0 个评论
采纳的回答
John D'Errico
2023-11-30
编辑:John D'Errico
2023-11-30
You can't have a polynomial that will fit that curve shape. They simply do not have that characteristic form. So using polyfit (and polyval) is therefore a waste of time.
t = (0:5:50)';
Teta1 = [0 19.727 25.705 28.796 30.154 31.375 31.787 31.961 31.164 32.504 32.285];
plot(t,Teta1,'o')
We see one of your curves above.As a first guess, a negative expoential model tht rises to a constant asymptote seems a good start.
mdl = fittype('a-b*exp(-t/c)','indep','t')
fittedmdl = fit(t,Teta1',mdl,'start',[30 30 10])
plot(fittedmdl,'b-')
hold on
plot(t,Teta1,'ro')
hold off
And we see at least a reasonable fit. Do the same for each of your curves.
Is that the correct choice of model? Well, probably not perfect. I would note that it is not constrained to pass exactly through zero at t==0. mdl2 does that.
mdl2 = fittype('a*(1-exp(-t/b))','indep','t')
fittedmdl2 = fit(t,Teta1',mdl2,'start',[30 10])
plot(fittedmdl2,'b-')
hold on
plot(t,Teta1,'ro')
The fit is similar in quality, but now it passes exactly through 0 at t==0. My guess is that would be your goal.
0 个评论
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Fit Postprocessing 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!