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 Center および File ExchangeMATLAB についてさらに検索

製品


リリース

R2018b

Community Treasure Hunt

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

Start Hunting!

Translated by