Fitting curve through data set
1 次查看(过去 30 天)
显示 更早的评论
Hi Im interested to plot XY which is a curve also Im interested to fit a best fit curve through data which should follow the data trend as is and then the point from where curve is changing or having maximum curvature, (X-value at that point) and a best fit line from the trend where values are straight to get intercept, After getting intercept I would like to use intercept and slop to draw another model on same graph. please see the attached figure for detailed idea.
Guide me please Thank you
4 个评论
采纳的回答
Chad Greene
2014-6-9
Given data at x and y, if you want a ytrend = m(xtrend) + b slope intercept form of the trend line, you can get it by
P = polyfit(x,y,1);
m = P(1);
b = P(2);
Make up some x values for the trend line:
xtrend = min(x):max(x);
Now the trend line is
ytrend = m*xtrend + b;
3 个评论
Chad Greene
2014-6-10
The steps above only calculate the trendline. After you've calculated the trend line, try
plot(x,y,'ro'); % plots your original data
hold on; % allows you to plot more data
plot(xtrend,ytrend,'k-') % plots the trend line
更多回答(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!