How to perform different RUNNING calculations on a financial Timetable.
2 ビュー (過去 30 日間)
古いコメントを表示
I have Stock data that I put in a Timetable. Several built in functions exists to perform calculations row by row for a SPECIFIC subset of data ex: tsmovavg (output = tsmovavg(tsobj,'e',timeperiod)) where timeperiod ex: 3 perform the calculation on the last 3 records. But, since those builtin functions are limited, I want to use other functions that could behave identically. For example, create a new variable that, for each row, would calculate the slope for the last 3 rows: coefficients = polyfit(A, B, 1); slope = coefficients(1)
Also, the trend based on the same 3 periods: mdl = fitlm(A,B,'linear'); Xnew = A; ypred = predict(mdl,Xnew);
Note that do not want to emphasize on the functions themselves but the ability to run through each row and perform a calculation base on n rows before and put the result in a new variable in my timetable, so at the end I'd have, for example, the slope at each rows BASED on the last 3 rows.
I'd like to use Matlab's power to not using loop and therefore reduce the numbers of code lines.
I reviewed a lot of possibilities, but none seems obvious but I'm shure there's a simpler way. Thanks all.
0 件のコメント
回答 (0 件)
参考
カテゴリ
Help Center および File Exchange で Logical についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!