matlab code question

조회 수: 2 (최근 30일)
Rambo
Rambo 2011년 4월 1일
I am new to matlab and need some help. Can somebody explain what the following code does? Isn't that going into an infinite loop?
Y(ii:ii+window-1).*hanw

답변 (2개)

Andrew Newell
Andrew Newell 2011년 4월 1일
I don't know what the variables are, but you're probably worried about the indexing. Let's take an example:
ii = 3;
window = 4;
ii:ii+window-1
ans =
3 4 5 6
It is a vector of consecutive integers, and Y(ii:ii+window-1) selects elements 3 to 6 of Y.

Matt Tearle
Matt Tearle 2011년 4월 1일
The colon in MATLAB is the range operator so ii:ii+window-1 gives the values ii, ii+1, ii+2, etc, for a total of window points. Hence this line of code extracts the window values of Y starting at the ii-th point, then multiplies them by the vector hanw.
  댓글 수: 1
Jan
Jan 2011년 4월 1일
... then multiplies them *elementwise* by the vector hanw.

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

카테고리

Help CenterFile Exchange에서 Loops and Conditional Statements에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by