필터 지우기
필터 지우기

Logical Manipulation of Vector

조회 수: 2 (최근 30일)
John
John 2011년 9월 5일
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
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일
a = 10;
b = 20;
lg = [true (a,1)
false(b,1)];

추가 답변 (2개)

Daniel Shub
Daniel Shub 2011년 9월 5일
[true(a, 1); false(b, 1)]

Walter Roberson
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
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... :(

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

카테고리

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

태그

제품

Community Treasure Hunt

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

Start Hunting!

Translated by