Logical Manipulation of Vector
2 次查看(过去 30 天)
显示 更早的评论
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 个评论
采纳的回答
更多回答(2 个)
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
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Logical 的更多信息
产品
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!