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
Paulo Silva 2011년 9월 5일
not easy to understand, please provide one simple example, rows=0 is something like this: []
Oleg Komarov
Oleg Komarov 2011년 9월 5일
He intended b rows of logical zeros.
Paulo Silva
Paulo Silva 2011년 9월 5일
thanks Oleg :) now I understand.

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

 채택된 답변

Oleg Komarov
Oleg Komarov 2011년 9월 5일

0 개 추천

a = 10;
b = 20;
lg = [true (a,1)
false(b,1)];

추가 답변 (2개)

Walter Roberson
Walter Roberson 2011년 9월 5일

0 개 추천

Something like,
kron([true;false],[a;b])
Unfortunately I cannot reach my server today to test this.

댓글 수: 2

Oleg Komarov
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
Walter Roberson 2011년 9월 6일
I usually get kron() wrong the first few times... :(

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

카테고리

도움말 센터File Exchange에서 Time Series Objects에 대해 자세히 알아보기

제품

태그

질문:

2011년 9월 5일

Community Treasure Hunt

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

Start Hunting!

Translated by