採用された回答

Star Strider
Star Strider 2020 年 6 月 8 日

0 投票

Try this:
M = diag([ones(1,9) 0 ones(1,9)]);
M = M + fliplr(M);
M(ceil(size(M,1)/2), ceil(size(M,1)/2)) = 1;
figure
imagesc(M)
axis('image')
colormap([0 0 0; 1 1 1])
No loops necessary.
Experiment to get different results.

2 件のコメント

Ekin Yilmaz
Ekin Yilmaz 2020 年 6 月 8 日
Very grateful, thank you. You're my hero.
Star Strider
Star Strider 2020 年 6 月 8 日
My pleasure!
If my Answer helped you solve your problem, please Accept it!
.

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

ヘルプ センター および File Exchange で Operating on Diagonal Matrices についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by