Labfans是一个针对大学生、工程师和科研工作者的技术社区。 论坛首页 | 联系我们(Contact Us)
MATLAB爱好者论坛-LabFans.com
返回   MATLAB爱好者论坛-LabFans.com > 其它 > 资料存档 > MATLAB技术文章
MATLAB技术文章 MATLAB Technical Articles From Mathworks
回复
 
主题工具 显示模式
旧 2022-08-16, 07:21   #1
poster
高级会员
 
注册日期: 2019-11-21
帖子: 3,006
声望力: 66
poster 正向着好的方向发展
默认 An Interesting, and Perhaps New, Matrix - Cleve Moler on Mathematics and Computing

I do not recall having seen this matrix before, but I will not be surprised to learn that somebody else already knows all about it, especially if that person's name is Nick.

Contents
Q

I've been investigating the matrices generated by this elegant one-liner.

Q = @(n) (-n:n).^2 + (-n:n)'.^2;The Q is for "quadratic".

The middle column contains the squares of the integers from -n to n. So does the middle row. The apostrophe summons singleton expansion. The resulting matrix has order 2*n+1. Here is Q(5).

Q5 = Q(5)Q5 = 50 41 34 29 26 25 26 29 34 41 50 41 32 25 20 17 16 17 20 25 32 41 34 25 18 13 10 9 10 13 18 25 34 29 20 13 8 5 4 5 8 13 20 29 26 17 10 5 2 1 2 5 10 17 26 25 16 9 4 1 0 1 4 9 16 25 26 17 10 5 2 1 2 5 10 17 26 29 20 13 8 5 4 5 8 13 20 29 34 25 18 13 10 9 10 13 18 25 34 41 32 25 20 17 16 17 20 25 32 41 50 41 34 29 26 25 26 29 34 41 50I like the contour plot.

contourf(Q(100)) axis square colorbar title('Q(100)') D

For another blog post under development, I need a logical mask that carves a circular region out of graphic. This disc does the job.

D = @(n) Q(n)
poster 当前离线   回复时引用此帖
回复


发帖规则
不可以发表新主题
不可以发表回复
不可以上传附件
不可以编辑自己的帖子

启用 BB 代码
论坛启用 表情符号
论坛启用 [IMG] 代码
论坛启用 HTML 代码



所有时间均为北京时间。现在的时间是 23:07


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