フィルターのクリア

Logical Manipulation of Vector

1 回表示 (過去 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 Center および File ExchangeLogical についてさらに検索

タグ

製品

Community Treasure Hunt

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

Start Hunting!

Translated by