How to create this matrix without using loop?

조회 수: 1 (최근 30일)
Andy Lau
Andy Lau 2018년 10월 12일
댓글: Image Analyst 2018년 10월 13일
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개)

Matt J
Matt J 2018년 10월 13일
편집: Matt J 2018년 10월 13일
a=cumsum(1:2:9);
result=min(a,a.'),

카테고리

Help CenterFile Exchange에서 MATLAB에 대해 자세히 알아보기

제품


릴리스

R2018b

Community Treasure Hunt

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

Start Hunting!

Translated by