How to create this matrix without using loop?

Hi,
I was wondering how to create this gradient matrix without using a loop ?
1 1 1 1 1
1 4 4 4 4
1 4 9 9 9
1 4 9 16 16
1 4 9 16 25
I already have the main diagonal completed using the following
x = 1 + cumsum(3:2:9)
I don't know how to do the rest, any help would be great.
Andy

Respuestas (1)

Matt J
Matt J el 13 de Oct. de 2018
Editada: Matt J el 13 de Oct. de 2018
a=cumsum(1:2:9);
result=min(a,a.'),

Categorías

Más información sobre MATLAB en Centro de ayuda y File Exchange.

Productos

Versión

R2018b

Preguntada:

el 12 de Oct. de 2018

Comentada:

el 13 de Oct. de 2018

Community Treasure Hunt

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

Start Hunting!

Translated by