Logical Manipulation of Vector
이전 댓글 표시
I require a logical vector with 'a' number of rows =1 and followed by 'b' rows =0. How can I create this without if statements?
I know a and b.
댓글 수: 3
Paulo Silva
2011년 9월 5일
not easy to understand, please provide one simple example, rows=0 is something like this: []
Oleg Komarov
2011년 9월 5일
He intended b rows of logical zeros.
Paulo Silva
2011년 9월 5일
thanks Oleg :) now I understand.
채택된 답변
추가 답변 (2개)
Daniel Shub
2011년 9월 5일
[true(a, 1); false(b, 1)]
Walter Roberson
2011년 9월 5일
Something like,
kron([true;false],[a;b])
Unfortunately I cannot reach my server today to test this.
댓글 수: 2
Oleg Komarov
2011년 9월 5일
It could have been the most elegant, although with some overhead but the result is:
ans =
10
15
0
0
Walter Roberson
2011년 9월 6일
I usually get kron() wrong the first few times... :(
카테고리
도움말 센터 및 File Exchange에서 Time Series Objects에 대해 자세히 알아보기
제품
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!