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

回答(1 个)

类别

帮助中心File Exchange 中查找有关 MATLAB 的更多信息

产品

版本

R2018b

提问:

2018-10-12

Community Treasure Hunt

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

Start Hunting!

Translated by