Generate a increasing increment array

7 visualizaciones (últimos 30 días)
Andy Lau
Andy Lau el 12 de Oct. de 2018
Respondida: Image Analyst el 13 de Oct. de 2018
Hi,
I was wondering how to generate array as follow
1 4 9 16 25
As you can see, the differences between them is
3 5 7 9
of increasing order. I was wondering how to do that without using any loop?
Thanks Andy

Respuesta aceptada

Walter Roberson
Walter Roberson el 12 de Oct. de 2018
1 + cumsum(3:2:9)

Más respuestas (1)

Image Analyst
Image Analyst el 13 de Oct. de 2018
Not sure what the rule is (actually I guess Walter figured it out since you accepted it), but here's another way:
>> v = (1:5).^2

Categorías

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

Etiquetas

Productos


Versión

R2018b

Community Treasure Hunt

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

Start Hunting!

Translated by