{"group":{"id":1,"name":"Community","lockable":false,"created_at":"2012-01-18T18:02:15.000Z","updated_at":"2025-12-14T01:33:56.000Z","description":"Problems submitted by members of the MATLAB Central community.","is_default":true,"created_by":161519,"badge_id":null,"featured":false,"trending":false,"solution_count_in_trending_period":0,"trending_last_calculated":"2025-12-14T00:00:00.000Z","image_id":null,"published":true,"community_created":false,"status_id":2,"is_default_group_for_player":false,"deleted_by":null,"deleted_at":null,"restored_by":null,"restored_at":null,"description_opc":null,"description_html":null,"published_at":null},"problems":[{"id":42752,"title":"Matrix diagonalization","description":"You will be given Two matrices A and B.\r\n\r\nReturn 1 if B is the diagonal matrix of A, 0 otherwise\r\n\r\n","description_html":"\u003cp\u003eYou will be given Two matrices A and B.\u003c/p\u003e\u003cp\u003eReturn 1 if B is the diagonal matrix of A, 0 otherwise\u003c/p\u003e","function_template":"function y = Check_Diag(A,B)\r\n  y = ;\r\nend","test_suite":"%%\r\nA=magic(3);\r\nB=[15.000000000000004                   0                   0\r\n                   0   4.898979485566359                   0\r\n                   0                   0  -4.898979485566358]\r\ny_correct=1;\r\nassert(isequal(Check_Diag(A,B),y_correct))\r\n\r\n\r\n%%\r\nA=eye(5);\r\nB=eye(5);\r\ny_correct=1;\r\nassert(isequal(Check_Diag(A,B),y_correct))\r\n\r\n%%\r\nA=spiral(2)\r\nB=[3     4\r\n     4     9];\r\ny_correct=0;\r\nassert(isequal(Check_Diag(A,B),y_correct))\r\n\r\n%%\r\nA=pascal(3)\r\nB=[ 1.127016653792583                   0                   0\r\n                   0   2.000000000000000                   0\r\n                   0                   0   8.872983346207416]\r\ny_correct=0;\r\nassert(isequal(Check_Diag(A,B),y_correct))\r\n\r\n%%\r\nA=spiral(3)\r\nB=[ 15.738398236975144                   0                   0\r\n                   0  -3.388172132922506                   0\r\n                   0                   0  -1.350226104052633];\r\ny_correct=1;\r\nassert(isequal(Check_Diag(A,B),y_correct))","published":true,"deleted":false,"likes_count":1,"comments_count":4,"created_by":17228,"edited_by":null,"edited_at":null,"deleted_by":null,"deleted_at":null,"solvers_count":39,"test_suite_updated_at":null,"rescore_all_solutions":false,"group_id":1,"created_at":"2016-02-24T14:45:35.000Z","updated_at":"2025-02-22T16:52:49.000Z","published_at":"2016-02-24T14:59:19.000Z","restored_at":null,"restored_by":null,"spam":false,"simulink":false,"admin_reviewed":false,"description_opc":"{\"relationships\":[{\"relationshipType\":\"http://schemas.mathworks.com/matlab/code/2013/relationships/document\",\"relationshipId\":\"rId1\",\"target\":\"/matlab/document.xml\"},{\"relationshipType\":\"http://schemas.mathworks.com/matlab/code/2013/relationships/output\",\"relationshipId\":\"rId2\",\"target\":\"/matlab/output.xml\"}],\"parts\":[{\"partUri\":\"/matlab/document.xml\",\"relationship\":[],\"contentType\":\"application/vnd.mathworks.matlab.code.document+xml\",\"content\":\"\u003c?xml version=\\\"1.0\\\" encoding=\\\"UTF-8\\\"?\u003e\u003cw:document xmlns:w=\\\"http://schemas.openxmlformats.org/wordprocessingml/2006/main\\\"\u003e\u003cw:body\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eYou will be given Two matrices A and B.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003cw:jc w:val=\\\"left\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eReturn 1 if B is the diagonal matrix of A, 0 otherwise\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003c/w:body\u003e\u003c/w:document\u003e\"},{\"partUri\":\"/matlab/output.xml\",\"contentType\":\"text/xml\",\"content\":\"\u003c?xml version=\\\"1.0\\\" encoding=\\\"UTF-8\\\" standalone=\\\"no\\\" ?\u003e\u003cembeddedOutputs\u003e\u003cmetaData\u003e\u003cevaluationState\u003emanual\u003c/evaluationState\u003e\u003clayoutState\u003ecode\u003c/layoutState\u003e\u003coutputStatus\u003eready\u003c/outputStatus\u003e\u003c/metaData\u003e\u003coutputArray type=\\\"array\\\"/\u003e\u003cregionArray type=\\\"array\\\"/\u003e\u003c/embeddedOutputs\u003e\"}]}"},{"id":45578,"title":"Create a matrix that counts up diagonally","description":"Given a single input _N_, create a _N_ x _N_ matrix that counts from 1 : _N_ ², (along up-right diagonals, starting with 1 in the top left corner. For example, given N=4...\r\n\r\n  1  3  6 10\r\n  2  5  9 13 \r\n  4  8 12 15 \r\n  7 11 14 16\r\n  \r\n\r\nNotice as you move up a row and right a column (↗) the values always increase by one. The value '1' should always go in the top left corner, with '2' directly below it. From there fill in the upward-rightward diagonals with the next higher integer until the matrix is complete. Assume N will always be a positive integer greater than 1 (N \u003e= 2).\r\n","description_html":"\u003cp\u003eGiven a single input \u003ci\u003eN\u003c/i\u003e, create a \u003ci\u003eN\u003c/i\u003e x \u003ci\u003eN\u003c/i\u003e matrix that counts from 1 : \u003ci\u003eN\u003c/i\u003e ², (along up-right diagonals, starting with 1 in the top left corner. For example, given N=4...\u003c/p\u003e\u003cpre class=\"language-matlab\"\u003e1  3  6 10\r\n2  5  9 13 \r\n4  8 12 15 \r\n7 11 14 16\r\n\u003c/pre\u003e\u003cp\u003eNotice as you move up a row and right a column (↗) the values always increase by one. The value '1' should always go in the top left corner, with '2' directly below it. From there fill in the upward-rightward diagonals with the next higher integer until the matrix is complete. Assume N will always be a positive integer greater than 1 (N \u0026gt;= 2).\u003c/p\u003e","function_template":"function mx = not_hankel(N)\r\n\r\n    mx = ones(N); %replace with your code\r\n\r\nend","test_suite":"%%\r\nN = 20;\r\n\r\nmx_correct = [...\r\n     1     3     6    10    15    21    28    36    45    55    66    78    91   105   120   136   153   171   190   210\r\n     2     5     9    14    20    27    35    44    54    65    77    90   104   119   135   152   170   189   209   229\r\n     4     8    13    19    26    34    43    53    64    76    89   103   118   134   151   169   188   208   228   247\r\n     7    12    18    25    33    42    52    63    75    88   102   117   133   150   168   187   207   227   246   264\r\n    11    17    24    32    41    51    62    74    87   101   116   132   149   167   186   206   226   245   263   280\r\n    16    23    31    40    50    61    73    86   100   115   131   148   166   185   205   225   244   262   279   295\r\n    22    30    39    49    60    72    85    99   114   130   147   165   184   204   224   243   261   278   294   309\r\n    29    38    48    59    71    84    98   113   129   146   164   183   203   223   242   260   277   293   308   322\r\n    37    47    58    70    83    97   112   128   145   163   182   202   222   241   259   276   292   307   321   334\r\n    46    57    69    82    96   111   127   144   162   181   201   221   240   258   275   291   306   320   333   345\r\n    56    68    81    95   110   126   143   161   180   200   220   239   257   274   290   305   319   332   344   355\r\n    67    80    94   109   125   142   160   179   199   219   238   256   273   289   304   318   331   343   354   364\r\n    79    93   108   124   141   159   178   198   218   237   255   272   288   303   317   330   342   353   363   372\r\n    92   107   123   140   158   177   197   217   236   254   271   287   302   316   329   341   352   362   371   379\r\n   106   122   139   157   176   196   216   235   253   270   286   301   315   328   340   351   361   370   378   385\r\n   121   138   156   175   195   215   234   252   269   285   300   314   327   339   350   360   369   377   384   390\r\n   137   155   174   194   214   233   251   268   284   299   313   326   338   349   359   368   376   383   389   394\r\n   154   173   193   213   232   250   267   283   298   312   325   337   348   358   367   375   382   388   393   397\r\n   172   192   212   231   249   266   282   297   311   324   336   347   357   366   374   381   387   392   396   399\r\n   191   211   230   248   265   281   296   310   323   335   346   356   365   373   380   386   391   395   398   400\r\n   ];\r\n\r\nassert(isequal(not_hankel(N),mx_correct))\r\n\r\n\r\n\r\n%%\r\nN = 3;\r\n\r\nmx_correct = [...\r\n     1     3     6\r\n     2     5     8\r\n     4     7     9\r\n     ];\r\n\r\nassert(isequal(not_hankel(N),mx_correct))\r\n\r\n\r\n\r\n%%\r\nrng('shuffle')\r\nN  = randi(99)+5;\r\nr = repmat((0:(N-1))',1,N) + (0:(N-1));\r\np = ((.5.*r.^2 + .5.*r) + (r(1,:)+1));\r\nq = rot90(hankel(fliplr(0:N-1)),2).^2;\r\nmx_correct = p - q;\r\nassert(isequal(not_hankel(N),mx_correct))\r\n\r\n\r\n\r\n%% \r\nN = 2;\r\nmx_correct =...\r\n[...\r\n    1  3\r\n    2  4 \r\n];\r\n\r\nassert(isequal(not_hankel(N),mx_correct))","published":true,"deleted":false,"likes_count":2,"comments_count":0,"created_by":18354,"edited_by":null,"edited_at":null,"deleted_by":null,"deleted_at":null,"solvers_count":22,"test_suite_updated_at":"2020-05-22T17:05:13.000Z","rescore_all_solutions":false,"group_id":1,"created_at":"2020-05-22T16:46:56.000Z","updated_at":"2026-01-20T13:24:26.000Z","published_at":"2020-05-22T16:46:56.000Z","restored_at":null,"restored_by":null,"spam":false,"simulink":false,"admin_reviewed":false,"description_opc":"{\"relationships\":[{\"relationshipType\":\"http://schemas.mathworks.com/matlab/code/2013/relationships/document\",\"targetMode\":\"\",\"relationshipId\":\"rId1\",\"target\":\"/matlab/document.xml\"},{\"relationshipType\":\"http://schemas.mathworks.com/matlab/code/2013/relationships/output\",\"targetMode\":\"\",\"relationshipId\":\"rId2\",\"target\":\"/matlab/output.xml\"}],\"parts\":[{\"partUri\":\"/matlab/document.xml\",\"relationship\":[],\"contentType\":\"application/vnd.mathworks.matlab.code.document+xml\",\"content\":\"\u003c?xml version=\\\"1.0\\\" encoding=\\\"UTF-8\\\"?\u003e\\n\u003cw:document xmlns:w=\\\"http://schemas.openxmlformats.org/wordprocessingml/2006/main\\\"\u003e\u003cw:body\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eGiven a single input\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:i/\u003e\u003c/w:rPr\u003e\u003cw:t\u003eN\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e, create a\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:i/\u003e\u003c/w:rPr\u003e\u003cw:t\u003eN\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e x\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:i/\u003e\u003c/w:rPr\u003e\u003cw:t\u003eN\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e matrix that counts from 1 :\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:i/\u003e\u003c/w:rPr\u003e\u003cw:t\u003eN\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e ², (along up-right diagonals, starting with 1 in the top left corner. For example, given N=4...\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"code\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003e\u003c![CDATA[1  3  6 10\\n2  5  9 13 \\n4  8 12 15 \\n7 11 14 16]]\u003e\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eNotice as you move up a row and right a column (↗) the values always increase by one. The value '1' should always go in the top left corner, with '2' directly below it. From there fill in the upward-rightward diagonals with the next higher integer until the matrix is complete. Assume N will always be a positive integer greater than 1 (N \u0026gt;= 2).\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003c/w:body\u003e\u003c/w:document\u003e\"},{\"partUri\":\"/matlab/output.xml\",\"contentType\":\"text/xml\",\"content\":\"\u003c?xml version=\\\"1.0\\\" encoding=\\\"UTF-8\\\" standalone=\\\"no\\\" ?\u003e\u003cembeddedOutputs\u003e\u003cmetaData\u003e\u003cevaluationState\u003emanual\u003c/evaluationState\u003e\u003clayoutState\u003ecode\u003c/layoutState\u003e\u003coutputStatus\u003eready\u003c/outputStatus\u003e\u003c/metaData\u003e\u003coutputArray type=\\\"array\\\"/\u003e\u003cregionArray type=\\\"array\\\"/\u003e\u003c/embeddedOutputs\u003e\"}]}"}],"problem_search":{"errors":[],"problems":[{"id":42752,"title":"Matrix diagonalization","description":"You will be given Two matrices A and B.\r\n\r\nReturn 1 if B is the diagonal matrix of A, 0 otherwise\r\n\r\n","description_html":"\u003cp\u003eYou will be given Two matrices A and B.\u003c/p\u003e\u003cp\u003eReturn 1 if B is the diagonal matrix of A, 0 otherwise\u003c/p\u003e","function_template":"function y = Check_Diag(A,B)\r\n  y = ;\r\nend","test_suite":"%%\r\nA=magic(3);\r\nB=[15.000000000000004                   0                   0\r\n                   0   4.898979485566359                   0\r\n                   0                   0  -4.898979485566358]\r\ny_correct=1;\r\nassert(isequal(Check_Diag(A,B),y_correct))\r\n\r\n\r\n%%\r\nA=eye(5);\r\nB=eye(5);\r\ny_correct=1;\r\nassert(isequal(Check_Diag(A,B),y_correct))\r\n\r\n%%\r\nA=spiral(2)\r\nB=[3     4\r\n     4     9];\r\ny_correct=0;\r\nassert(isequal(Check_Diag(A,B),y_correct))\r\n\r\n%%\r\nA=pascal(3)\r\nB=[ 1.127016653792583                   0                   0\r\n                   0   2.000000000000000                   0\r\n                   0                   0   8.872983346207416]\r\ny_correct=0;\r\nassert(isequal(Check_Diag(A,B),y_correct))\r\n\r\n%%\r\nA=spiral(3)\r\nB=[ 15.738398236975144                   0                   0\r\n                   0  -3.388172132922506                   0\r\n                   0                   0  -1.350226104052633];\r\ny_correct=1;\r\nassert(isequal(Check_Diag(A,B),y_correct))","published":true,"deleted":false,"likes_count":1,"comments_count":4,"created_by":17228,"edited_by":null,"edited_at":null,"deleted_by":null,"deleted_at":null,"solvers_count":39,"test_suite_updated_at":null,"rescore_all_solutions":false,"group_id":1,"created_at":"2016-02-24T14:45:35.000Z","updated_at":"2025-02-22T16:52:49.000Z","published_at":"2016-02-24T14:59:19.000Z","restored_at":null,"restored_by":null,"spam":false,"simulink":false,"admin_reviewed":false,"description_opc":"{\"relationships\":[{\"relationshipType\":\"http://schemas.mathworks.com/matlab/code/2013/relationships/document\",\"relationshipId\":\"rId1\",\"target\":\"/matlab/document.xml\"},{\"relationshipType\":\"http://schemas.mathworks.com/matlab/code/2013/relationships/output\",\"relationshipId\":\"rId2\",\"target\":\"/matlab/output.xml\"}],\"parts\":[{\"partUri\":\"/matlab/document.xml\",\"relationship\":[],\"contentType\":\"application/vnd.mathworks.matlab.code.document+xml\",\"content\":\"\u003c?xml version=\\\"1.0\\\" encoding=\\\"UTF-8\\\"?\u003e\u003cw:document xmlns:w=\\\"http://schemas.openxmlformats.org/wordprocessingml/2006/main\\\"\u003e\u003cw:body\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eYou will be given Two matrices A and B.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003cw:jc w:val=\\\"left\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eReturn 1 if B is the diagonal matrix of A, 0 otherwise\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003c/w:body\u003e\u003c/w:document\u003e\"},{\"partUri\":\"/matlab/output.xml\",\"contentType\":\"text/xml\",\"content\":\"\u003c?xml version=\\\"1.0\\\" encoding=\\\"UTF-8\\\" standalone=\\\"no\\\" ?\u003e\u003cembeddedOutputs\u003e\u003cmetaData\u003e\u003cevaluationState\u003emanual\u003c/evaluationState\u003e\u003clayoutState\u003ecode\u003c/layoutState\u003e\u003coutputStatus\u003eready\u003c/outputStatus\u003e\u003c/metaData\u003e\u003coutputArray type=\\\"array\\\"/\u003e\u003cregionArray type=\\\"array\\\"/\u003e\u003c/embeddedOutputs\u003e\"}]}"},{"id":45578,"title":"Create a matrix that counts up diagonally","description":"Given a single input _N_, create a _N_ x _N_ matrix that counts from 1 : _N_ ², (along up-right diagonals, starting with 1 in the top left corner. For example, given N=4...\r\n\r\n  1  3  6 10\r\n  2  5  9 13 \r\n  4  8 12 15 \r\n  7 11 14 16\r\n  \r\n\r\nNotice as you move up a row and right a column (↗) the values always increase by one. The value '1' should always go in the top left corner, with '2' directly below it. From there fill in the upward-rightward diagonals with the next higher integer until the matrix is complete. Assume N will always be a positive integer greater than 1 (N \u003e= 2).\r\n","description_html":"\u003cp\u003eGiven a single input \u003ci\u003eN\u003c/i\u003e, create a \u003ci\u003eN\u003c/i\u003e x \u003ci\u003eN\u003c/i\u003e matrix that counts from 1 : \u003ci\u003eN\u003c/i\u003e ², (along up-right diagonals, starting with 1 in the top left corner. For example, given N=4...\u003c/p\u003e\u003cpre class=\"language-matlab\"\u003e1  3  6 10\r\n2  5  9 13 \r\n4  8 12 15 \r\n7 11 14 16\r\n\u003c/pre\u003e\u003cp\u003eNotice as you move up a row and right a column (↗) the values always increase by one. The value '1' should always go in the top left corner, with '2' directly below it. From there fill in the upward-rightward diagonals with the next higher integer until the matrix is complete. Assume N will always be a positive integer greater than 1 (N \u0026gt;= 2).\u003c/p\u003e","function_template":"function mx = not_hankel(N)\r\n\r\n    mx = ones(N); %replace with your code\r\n\r\nend","test_suite":"%%\r\nN = 20;\r\n\r\nmx_correct = [...\r\n     1     3     6    10    15    21    28    36    45    55    66    78    91   105   120   136   153   171   190   210\r\n     2     5     9    14    20    27    35    44    54    65    77    90   104   119   135   152   170   189   209   229\r\n     4     8    13    19    26    34    43    53    64    76    89   103   118   134   151   169   188   208   228   247\r\n     7    12    18    25    33    42    52    63    75    88   102   117   133   150   168   187   207   227   246   264\r\n    11    17    24    32    41    51    62    74    87   101   116   132   149   167   186   206   226   245   263   280\r\n    16    23    31    40    50    61    73    86   100   115   131   148   166   185   205   225   244   262   279   295\r\n    22    30    39    49    60    72    85    99   114   130   147   165   184   204   224   243   261   278   294   309\r\n    29    38    48    59    71    84    98   113   129   146   164   183   203   223   242   260   277   293   308   322\r\n    37    47    58    70    83    97   112   128   145   163   182   202   222   241   259   276   292   307   321   334\r\n    46    57    69    82    96   111   127   144   162   181   201   221   240   258   275   291   306   320   333   345\r\n    56    68    81    95   110   126   143   161   180   200   220   239   257   274   290   305   319   332   344   355\r\n    67    80    94   109   125   142   160   179   199   219   238   256   273   289   304   318   331   343   354   364\r\n    79    93   108   124   141   159   178   198   218   237   255   272   288   303   317   330   342   353   363   372\r\n    92   107   123   140   158   177   197   217   236   254   271   287   302   316   329   341   352   362   371   379\r\n   106   122   139   157   176   196   216   235   253   270   286   301   315   328   340   351   361   370   378   385\r\n   121   138   156   175   195   215   234   252   269   285   300   314   327   339   350   360   369   377   384   390\r\n   137   155   174   194   214   233   251   268   284   299   313   326   338   349   359   368   376   383   389   394\r\n   154   173   193   213   232   250   267   283   298   312   325   337   348   358   367   375   382   388   393   397\r\n   172   192   212   231   249   266   282   297   311   324   336   347   357   366   374   381   387   392   396   399\r\n   191   211   230   248   265   281   296   310   323   335   346   356   365   373   380   386   391   395   398   400\r\n   ];\r\n\r\nassert(isequal(not_hankel(N),mx_correct))\r\n\r\n\r\n\r\n%%\r\nN = 3;\r\n\r\nmx_correct = [...\r\n     1     3     6\r\n     2     5     8\r\n     4     7     9\r\n     ];\r\n\r\nassert(isequal(not_hankel(N),mx_correct))\r\n\r\n\r\n\r\n%%\r\nrng('shuffle')\r\nN  = randi(99)+5;\r\nr = repmat((0:(N-1))',1,N) + (0:(N-1));\r\np = ((.5.*r.^2 + .5.*r) + (r(1,:)+1));\r\nq = rot90(hankel(fliplr(0:N-1)),2).^2;\r\nmx_correct = p - q;\r\nassert(isequal(not_hankel(N),mx_correct))\r\n\r\n\r\n\r\n%% \r\nN = 2;\r\nmx_correct =...\r\n[...\r\n    1  3\r\n    2  4 \r\n];\r\n\r\nassert(isequal(not_hankel(N),mx_correct))","published":true,"deleted":false,"likes_count":2,"comments_count":0,"created_by":18354,"edited_by":null,"edited_at":null,"deleted_by":null,"deleted_at":null,"solvers_count":22,"test_suite_updated_at":"2020-05-22T17:05:13.000Z","rescore_all_solutions":false,"group_id":1,"created_at":"2020-05-22T16:46:56.000Z","updated_at":"2026-01-20T13:24:26.000Z","published_at":"2020-05-22T16:46:56.000Z","restored_at":null,"restored_by":null,"spam":false,"simulink":false,"admin_reviewed":false,"description_opc":"{\"relationships\":[{\"relationshipType\":\"http://schemas.mathworks.com/matlab/code/2013/relationships/document\",\"targetMode\":\"\",\"relationshipId\":\"rId1\",\"target\":\"/matlab/document.xml\"},{\"relationshipType\":\"http://schemas.mathworks.com/matlab/code/2013/relationships/output\",\"targetMode\":\"\",\"relationshipId\":\"rId2\",\"target\":\"/matlab/output.xml\"}],\"parts\":[{\"partUri\":\"/matlab/document.xml\",\"relationship\":[],\"contentType\":\"application/vnd.mathworks.matlab.code.document+xml\",\"content\":\"\u003c?xml version=\\\"1.0\\\" encoding=\\\"UTF-8\\\"?\u003e\\n\u003cw:document xmlns:w=\\\"http://schemas.openxmlformats.org/wordprocessingml/2006/main\\\"\u003e\u003cw:body\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eGiven a single input\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:i/\u003e\u003c/w:rPr\u003e\u003cw:t\u003eN\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e, create a\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:i/\u003e\u003c/w:rPr\u003e\u003cw:t\u003eN\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e x\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:i/\u003e\u003c/w:rPr\u003e\u003cw:t\u003eN\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e matrix that counts from 1 :\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:i/\u003e\u003c/w:rPr\u003e\u003cw:t\u003eN\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e ², (along up-right diagonals, starting with 1 in the top left corner. For example, given N=4...\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"code\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003e\u003c![CDATA[1  3  6 10\\n2  5  9 13 \\n4  8 12 15 \\n7 11 14 16]]\u003e\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eNotice as you move up a row and right a column (↗) the values always increase by one. The value '1' should always go in the top left corner, with '2' directly below it. From there fill in the upward-rightward diagonals with the next higher integer until the matrix is complete. Assume N will always be a positive integer greater than 1 (N \u0026gt;= 2).\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003c/w:body\u003e\u003c/w:document\u003e\"},{\"partUri\":\"/matlab/output.xml\",\"contentType\":\"text/xml\",\"content\":\"\u003c?xml version=\\\"1.0\\\" encoding=\\\"UTF-8\\\" standalone=\\\"no\\\" ?\u003e\u003cembeddedOutputs\u003e\u003cmetaData\u003e\u003cevaluationState\u003emanual\u003c/evaluationState\u003e\u003clayoutState\u003ecode\u003c/layoutState\u003e\u003coutputStatus\u003eready\u003c/outputStatus\u003e\u003c/metaData\u003e\u003coutputArray type=\\\"array\\\"/\u003e\u003cregionArray type=\\\"array\\\"/\u003e\u003c/embeddedOutputs\u003e\"}]}"}],"term":"tag:\"diagonal matrix\"","current_player_id":null,"fields":[{"name":"page","type":"integer","callback":null,"default":1,"directive":null,"facet":null,"facet_method":"and","operator":null,"param":null,"static":null,"prepend":true},{"name":"per_page","type":"integer","callback":null,"default":50,"directive":null,"facet":null,"facet_method":"and","operator":null,"param":null,"static":null,"prepend":true},{"name":"sort","type":"string","callback":null,"default":null,"directive":null,"facet":null,"facet_method":"and","operator":null,"param":null,"static":null,"prepend":true},{"name":"body","type":"text","callback":null,"default":"*:*","directive":null,"facet":null,"facet_method":"and","operator":null,"param":"term","static":null,"prepend":false},{"name":"group","type":"string","callback":null,"default":null,"directive":"group","facet":true,"facet_method":"and","operator":null,"param":"term","static":null,"prepend":true},{"name":"difficulty_rating_bin","type":"string","callback":null,"default":null,"directive":"difficulty_rating_bin","facet":true,"facet_method":"and","operator":null,"param":"term","static":null,"prepend":true},{"name":"id","type":"integer","callback":null,"default":null,"directive":"id","facet":null,"facet_method":"and","operator":null,"param":"term","static":null,"prepend":true},{"name":"tag","type":"string","callback":null,"default":null,"directive":"tag","facet":null,"facet_method":"and","operator":null,"param":"term","static":null,"prepend":true},{"name":"product","type":"string","callback":null,"default":null,"directive":"product","facet":null,"facet_method":"and","operator":null,"param":"term","static":null,"prepend":true},{"name":"created_at","type":"timeframe","callback":{},"default":null,"directive":"created_at","facet":null,"facet_method":"and","operator":null,"param":"term","static":null,"prepend":true},{"name":"profile_id","type":"integer","callback":null,"default":null,"directive":"author_id","facet":null,"facet_method":"and","operator":null,"param":"term","static":null,"prepend":true},{"name":"created_by","type":"string","callback":null,"default":null,"directive":"author","facet":null,"facet_method":"and","operator":null,"param":"term","static":null,"prepend":true},{"name":"player_id","type":"integer","callback":null,"default":null,"directive":"solver_id","facet":null,"facet_method":"and","operator":null,"param":"term","static":null,"prepend":true},{"name":"player","type":"string","callback":null,"default":null,"directive":"solver","facet":null,"facet_method":"and","operator":null,"param":"term","static":null,"prepend":true},{"name":"solvers_count","type":"integer","callback":null,"default":null,"directive":"solvers_count","facet":null,"facet_method":"and","operator":null,"param":"term","static":null,"prepend":true},{"name":"comments_count","type":"integer","callback":null,"default":null,"directive":"comments_count","facet":null,"facet_method":"and","operator":null,"param":"term","static":null,"prepend":true},{"name":"likes_count","type":"integer","callback":null,"default":null,"directive":"likes_count","facet":null,"facet_method":"and","operator":null,"param":"term","static":null,"prepend":true},{"name":"leader_id","type":"integer","callback":null,"default":null,"directive":"leader_id","facet":null,"facet_method":"and","operator":null,"param":"term","static":null,"prepend":true},{"name":"leading_solution","type":"integer","callback":null,"default":null,"directive":"leading_solution","facet":null,"facet_method":"and","operator":null,"param":"term","static":null,"prepend":true}],"filters":[{"name":"asset_type","type":"string","callback":null,"default":null,"directive":null,"facet":null,"facet_method":"and","operator":null,"param":null,"static":"\"cody:problem\"","prepend":true},{"name":"profile_id","type":"integer","callback":{},"default":null,"directive":null,"facet":null,"facet_method":"and","operator":null,"param":"author_id","static":null,"prepend":true}],"query":{"params":{"per_page":50,"term":"tag:\"diagonal matrix\"","current_player":null,"sort":"map(difficulty_value,0,0,999) asc"},"parser":"MathWorks::Search::Solr::QueryParser","directives":{"term":{"directives":{"tag":[["tag:\"diagonal matrix\"","","\"","diagonal matrix","\""]]}}},"facets":{"#\u003cMathWorks::Search::Field:0x00007f45de1ac3b0\u003e":null,"#\u003cMathWorks::Search::Field:0x00007f45de1ac310\u003e":null},"filters":{"#\u003cMathWorks::Search::Field:0x00007f45de1aba50\u003e":"\"cody:problem\""},"fields":{"#\u003cMathWorks::Search::Field:0x00007f45de1ac630\u003e":1,"#\u003cMathWorks::Search::Field:0x00007f45de1ac590\u003e":50,"#\u003cMathWorks::Search::Field:0x00007f45de1ac4f0\u003e":"map(difficulty_value,0,0,999) asc","#\u003cMathWorks::Search::Field:0x00007f45de1ac450\u003e":"tag:\"diagonal matrix\""},"user_query":{"#\u003cMathWorks::Search::Field:0x00007f45de1ac450\u003e":"tag:\"diagonal matrix\""},"queried_facets":{}},"query_backend":{"connection":{"configuration":{"index_url":"http://index-op-v2/solr/","query_url":"http://search-op-v2/solr/","direct_access_index_urls":["http://index-op-v2/solr/"],"direct_access_query_urls":["http://search-op-v2/solr/"],"timeout":10,"vhost":"search","exchange":"search.topic","heartbeat":30,"pre_index_mode":false,"host":"rabbitmq-eks","port":5672,"username":"search","password":"J3bGPZzQ7asjJcCk","virtual_host":"search","indexer":"amqp","http_logging":"true","core":"cody"},"query_connection":{"uri":"http://search-op-v2/solr/cody/","proxy":null,"connection":{"parallel_manager":null,"headers":{"User-Agent":"Faraday v1.0.1"},"params":{},"options":{"params_encoder":"Faraday::FlatParamsEncoder","proxy":null,"bind":null,"timeout":null,"open_timeout":null,"read_timeout":null,"write_timeout":null,"boundary":null,"oauth":null,"context":null,"on_data":null},"ssl":{"verify":true,"ca_file":null,"ca_path":null,"verify_mode":null,"cert_store":null,"client_cert":null,"client_key":null,"certificate":null,"private_key":null,"verify_depth":null,"version":null,"min_version":null,"max_version":null},"default_parallel_manager":null,"builder":{"adapter":{"name":"Faraday::Adapter::NetHttp","args":[],"block":null},"handlers":[{"name":"Faraday::Response::RaiseError","args":[],"block":null}],"app":{"app":{"ssl_cert_store":{"verify_callback":null,"error":null,"error_string":null,"chain":null,"time":null},"app":{},"connection_options":{},"config_block":null}}},"url_prefix":"http://search-op-v2/solr/cody/","manual_proxy":false,"proxy":null},"update_format":"RSolr::JSON::Generator","update_path":"update","options":{"url":"http://search-op-v2/solr/cody"}}},"query":{"params":{"per_page":50,"term":"tag:\"diagonal matrix\"","current_player":null,"sort":"map(difficulty_value,0,0,999) asc"},"parser":"MathWorks::Search::Solr::QueryParser","directives":{"term":{"directives":{"tag":[["tag:\"diagonal matrix\"","","\"","diagonal matrix","\""]]}}},"facets":{"#\u003cMathWorks::Search::Field:0x00007f45de1ac3b0\u003e":null,"#\u003cMathWorks::Search::Field:0x00007f45de1ac310\u003e":null},"filters":{"#\u003cMathWorks::Search::Field:0x00007f45de1aba50\u003e":"\"cody:problem\""},"fields":{"#\u003cMathWorks::Search::Field:0x00007f45de1ac630\u003e":1,"#\u003cMathWorks::Search::Field:0x00007f45de1ac590\u003e":50,"#\u003cMathWorks::Search::Field:0x00007f45de1ac4f0\u003e":"map(difficulty_value,0,0,999) asc","#\u003cMathWorks::Search::Field:0x00007f45de1ac450\u003e":"tag:\"diagonal matrix\""},"user_query":{"#\u003cMathWorks::Search::Field:0x00007f45de1ac450\u003e":"tag:\"diagonal matrix\""},"queried_facets":{}},"options":{"fields":["id","difficulty_rating"]},"join":" "},"results":[{"id":42752,"difficulty_rating":"easy"},{"id":45578,"difficulty_rating":"medium"}]}}