How to create this matrix without using loop?

1 Ansicht (letzte 30 Tage)
Andy Lau
Andy Lau am 12 Okt. 2018
Kommentiert: Image Analyst am 13 Okt. 2018
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

Antworten (1)

Matt J
Matt J am 13 Okt. 2018
Bearbeitet: Matt J am 13 Okt. 2018
a=cumsum(1:2:9);
result=min(a,a.'),

Kategorien

Mehr zu MATLAB finden Sie in Help Center und File Exchange

Produkte


Version

R2018b

Community Treasure Hunt

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

Start Hunting!

Translated by