MATLAB爱好者论坛-LabFans.com

MATLAB爱好者论坛-LabFans.com (https://www.labfans.com/bbs/index.php)
-   资料存档 (https://www.labfans.com/bbs/forumdisplay.php?f=72)
-   -   如何在Matlab中创建此矩阵? (https://www.labfans.com/bbs/showthread.php?t=23745)

poster 2019-12-10 20:48

如何在Matlab中创建此矩阵?
 
我正在尝试解决[URL="https://stackoverflow.com/questions/3365487/code-golf-build-me-an-arc/3369332#3369332"]Code Golf:Build Me a Arc[/URL]问题。我的解决方案还不错,但是我认为,有一种更简单的方法可以做到这一点。给定n ,有人知道如何生成这样的nxn矩阵吗?我花了57个字符!

3 0 0 0 2 0 0 0 1 0 3 0 0 2 0 0 1 0 0 0 3 0 2 0 1 0 0 0 0 0 3 2 1 0 0 0 4 4 4 4 8 8 8 8 8 0 0 0 5 6 7 0 0 0 0 0 5 0 6 0 7 0 0 0 5 0 0 6 0 0 7 0 5 0 0 0 6 0 0 0 7 我想将其中的一些[URL="http://www.mathworks.com/access/helpdesk/help/techdoc/ref/f16-5872.html#f16-6070"]矩阵[/URL]弄巧成拙。

[B]更新: [/B]

这就是我现在得到的方式。

%%# Create the grid [XY]=meshgrid(-r:r); %%# Compute the angles in degrees T=atan2(-Y,X)/pi*180; %%# Get all the angles T=T+(T


所有时间均为北京时间。现在的时间是 01:04

Powered by vBulletin
版权所有 ©2000 - 2025,Jelsoft Enterprises Ltd.