plot an exponential curve to connect between two points
5 次查看(过去 30 天)
显示 更早的评论
I want to draw a curve in a negative exponential shape like this green one:
I use this code (to join between point 38 and -52 by negative exponential curve):
x1 = -52;
y1 = 0.0101836;
x2 = 38;
y2=0.000359214;
dy=y1-y2;
dx=x2-x1;
k=0.3;
f=@(x) dy.*exp(-k*(x+dx))+y2;
xx=linspace(x1,x2,100);
yy=f(xx);
plot(xx,yy,'g--','LineWidth',2);
plot([38,38],[0.008 0.1],'g--','linewidth',1)
but unfortunately I got a straight line instead of exponential curve:
How could I adjust the code to get the green curve?
4 个评论
John D'Errico
2016-3-28
What does this have to do with extrapolation? Extrapolation uses information from data that you have, then predicts values outside of the domain of your data using that information. So this actually has NOTHING to do with extrapolation. All you are asking is how to connect two points with some random curve.
Anyway, there is NO purely exponential curve that connects those two points.
Given my statement (which is true) then you need to choose some arbitrary form for an exponential-like curve. Sadly, there are infinitely many exponential-like curves that COULD pass through those two points.
回答(2 个)
Walter Roberson
2016-3-29
Exponential curves are never 0 except at infinity. You cannot use an exponential curve to connect to (38,0)
If you are willing to have the (38,0) be (38,epsilon) for some non-negative epsilon, then
N = 30; %adjust as desired, number of points in the curve including endpoints
smooth_y = 10.^logspace( log(0.1), log(epsilon), N);
smooth_x = linspace(-52, 38, N);
plot(smooth_x, smooth_y);
0 个评论
Image Analyst
2016-3-29
Perhaps you should consider the Wiebull distribution: https://en.wikipedia.org/wiki/Weibull_distribution : "..... the Weibull distribution gives a distribution for which the failure rate is proportional to a power of time......"
The Weibull parameters are estimated by the function wblpdf() in the Statistics and Machine Learning Toolbox: http://www.mathworks.com/help/stats/wblpdf.html?s_tid=srchtitle
0 个评论
另请参阅
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!