MATLAB爱好者论坛-LabFans.com

MATLAB爱好者论坛-LabFans.com (https://www.labfans.com/bbs/index.php)
-   MATLAB技术文章 (https://www.labfans.com/bbs/forumdisplay.php?f=25)
-   -   An Interesting, and Perhaps New, Matrix - Cleve Moler on Mathematics and Computing (https://www.labfans.com/bbs/showthread.php?t=27344)

poster 2022-08-16 07:21

An Interesting, and Perhaps New, Matrix - Cleve Moler on Mathematics and Computing
 
<div class="content">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.

[B]Contents[/B]
[LIST][*][URL="https://www.labfans.com/bbs/#17afe407-67a2-462b-a10b-df348fccb837"]Q[/URL][*][URL="https://www.labfans.com/bbs/#044996c2-78b8-4a23-a809-6ed8ab3e3607"]D[/URL][*][URL="https://www.labfans.com/bbs/#eca1bb02-1ba1-4bbf-9ed0-39c244e018eb"]O.E.I.S.[/URL][*][URL="https://www.labfans.com/bbs/#b7778074-8d3f-46ad-858b-13f27d2f99bd"]R[/URL][*][URL="https://www.labfans.com/bbs/#1e78f08f-c39d-4810-93bb-b0428456710c"]Condition[/URL][*][URL="https://www.labfans.com/bbs/#c60c371e-4378-4499-8242-376b1b37da8c"]Extra Credit[/URL][/LIST][B]Q[/B]

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)')[IMG]http://blogs.mathworks.com/cleve/files/disc_blog_01.png[/IMG] [B]D[/B]

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)


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

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