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 comentarios

Paulo Silva
Paulo Silva el 5 de Sept. de 2011
not easy to understand, please provide one simple example, rows=0 is something like this: []
Oleg Komarov
Oleg Komarov el 5 de Sept. de 2011
He intended b rows of logical zeros.
Paulo Silva
Paulo Silva el 5 de Sept. de 2011
thanks Oleg :) now I understand.

Iniciar sesión para comentar.

 Respuesta aceptada

Oleg Komarov
Oleg Komarov el 5 de Sept. de 2011

0 votos

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

Más respuestas (2)

Walter Roberson
Walter Roberson el 5 de Sept. de 2011

0 votos

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

2 comentarios

Oleg Komarov
Oleg Komarov el 5 de Sept. de 2011
It could have been the most elegant, although with some overhead but the result is:
ans =
10
15
0
0
Walter Roberson
Walter Roberson el 6 de Sept. de 2011
I usually get kron() wrong the first few times... :(

Iniciar sesión para comentar.

Categorías

Productos

Etiquetas

Preguntada:

el 5 de Sept. de 2011

Community Treasure Hunt

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

Start Hunting!

Translated by