# How can I create a vector of rolling Standard Deviations

조회 수: 2 (최근 30일)
Nico 2014년 7월 21일
댓글: Nico 2014년 7월 21일
Hi !
I'am sure this is an easy question for most of you...
I have a timeseries 'T' and I wanted to convert this into a vector 'V' of rolling Standard deviations. So every element of 'V' is the Std of the previous 30 elements of 'T'. The first thirty elements of 'V' are NaN then, right?
Could someone pleas help me with this problem?
Thanks, Nico

댓글을 달려면 로그인하십시오.

### 채택된 답변

Shashank Prasanna 2014년 7월 21일
It is preferred if you give it a shot first and then seek help,
w = 30;
y = NaN(100,1)
x = randn(100,1);
for ii = w+1:100
y(ii,1) = var(x(ii-w:ii-1,1));
end
The first 30 need not be NaN, you can make them zero if you prefer.
##### 댓글 수: 1이전 댓글 -1개 표시이전 댓글 -1개 숨기기
Nico 2014년 7월 21일
Thank you - that helps !

댓글을 달려면 로그인하십시오.

### 카테고리

Help CenterFile Exchange에서 MATLAB에 대해 자세히 알아보기

### Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by