Borrar filtros
Borrar filtros

Repeat a vector with increment

8 visualizaciones (últimos 30 días)
John
John el 30 de Dic. de 2016
Editada: Azzi Abdelmalek el 30 de Dic. de 2016
Given
vector a = (1:N)'; with N consecutive integers
how to generate
matrix b = [a a+1 a+2 ... a+M]; with M columns, each column incremented by one.
For example
N = 3; M = 3;
a = (1:3)';
b = [(1:3)' (2:4)' (3:5)' (4:6)'];

Respuesta aceptada

Star Strider
Star Strider el 30 de Dic. de 2016
This works:
N = 3;
M = 3;
a = (1:3)';
b = bsxfun(@plus, a, [0:M-1])
b =
1 2 3
2 3 4
3 4 5

Más respuestas (0)

Categorías

Más información sobre MATLAB Coder en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by