How to set up Vectorization properly?

1 visualización (últimos 30 días)
Maxwell Barton
Maxwell Barton el 11 de Sept. de 2019
Editada: Stephen23 el 11 de Sept. de 2019
I am trying to set up a list like as the example shown below. Basically it starts with 1 to 4, then jumps by 13, then proceeds another 4 then jumps by 13 again.
I understand I can do 1:13:end to get a simple 1,14,27 etc list by how would I go about doing this alternative list in vectorised format?
Thanks.
X = [1,2,3,4,17,18,19,20,33,34,35,36...]

Respuesta aceptada

Stephen23
Stephen23 el 11 de Sept. de 2019
Editada: Stephen23 el 11 de Sept. de 2019
>> reshape(bsxfun(@plus,(1:4).',0:16:16*3),1,[])
ans =
1 2 3 4 17 18 19 20 33 34 35 36 49 50 51 52
MATLAB versions since R2016b:
>> reshape((1:4).'+(0:16:16*3),1,[])
ans =
1 2 3 4 17 18 19 20 33 34 35 36 49 50 51 52

Más respuestas (0)

Categorías

Más información sobre Resizing and Reshaping Matrices en Help Center y File Exchange.

Etiquetas

Productos


Versión

R2018a

Community Treasure Hunt

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

Start Hunting!

Translated by