fit the y=mx+c in time series
1 次查看(过去 30 天)
显示 更早的评论
Hi. I have 420x1 data of time series.
How can I fit y=mx+c line in the plotting?
0 个评论
回答(1 个)
Star Strider
2021-3-28
That could be a challenge.
dt = datetime('now')+days(1:10);
T1 = table(dt(:), rand(10,1)+(0.1:0.1:1).');
B = [day(T1.Var1) ones(size(T1.Var1))] \ T1.Var2;
LinFit = [day(T1.Var1) ones(size(T1.Var1))] * B;
figure
plot(T1.Var1, T1.Var2, 'p')
hold on
plot(T1.Var1, LinFit, '-r')
hold off
grid
Depending on the time series, the results could appear a bit unusual.
.
4 个评论
Star Strider
2021-3-28
My pleasure!
Did I provide a meaningful solution?
If not, what do you want to do?
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Graphics Object Programming 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!