Last value of Moving Average in single command
조회 수: 1 (최근 30일)
이전 댓글 표시
Hi,
I have A = rand(10,1). I am calculating an exponential moving average, B = movavg(A,'exponential',2). I only want the last value of B, i.e. C = B(end).
Is there any way to do this in a single command?
Thank you!
IP
댓글 수: 0
채택된 답변
Voss
2022년 6월 29일
Here's a way:
A = rand(10,1);
% original, for reference:
B = movavg(A,'exponential',2);
C = B(end)
% single-line command:
C = subsref(movavg(A,'exponential',2),substruct('()',{numel(A)}))
추가 답변 (0개)
참고 항목
제품
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!