how to interpret this expression?
조회 수: 1 (최근 30일)
이전 댓글 표시
Could you please put the braces for this expression. I mean does this expression mean
a) a( N - winLength * 2 : N )=0; this
1) a( N - ( winLength * 2 ) : N ) = 0; or
2) a( ( N - winLength ) * 2 : N ) = 0;
n the same with this expression also
b) a ( 1 : winLength * 2 ) = 0;
1) a ( 1 : ( winLength * 2 ) ) = 0; or
2) a ( (1 : winLength ) * 2 ) = 0;
댓글 수: 0
채택된 답변
David Sanchez
2013년 5월 23일
Let us suppose
a = [1 2 3 4 5 6 7 8]; winLength = 3; N = 7;
- a( N - winLength * 2 : N )=0 -> elements from N-winLength*2 till element N is zero: N-winLength*2 = 7-3*2=1 -> a(1:7)=0 a = [0 0 0 0 0 0 0 8]
- a( N - ( winLength * 2 ) : N ) = 0 -> same than above
- a( ( N - winLength ) * 2 : N ) = 0 -> (N-winLength)*2=(7-3)*2 =4*2=8 -> a(8:7) -> this produces an empty matrix for the example presented, but I'm sure you can think about any other example.
- a(1:winLength*2) = 0 is the same than a(1:(winLength*2)) = 0 -> a(1:3*2) = a(1:6) = [1 2 3 4 5 6]
- a((1:winLength)*2) = a((1:3)*2) = a(1:3)*2 = [2 4 6]
추가 답변 (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!