{"id":215,"date":"2021-06-07T14:22:56","date_gmt":"2021-06-07T06:22:56","guid":{"rendered":"https:\/\/swordofmorning.com\/?p=215"},"modified":"2025-10-09T13:56:21","modified_gmt":"2025-10-09T05:56:21","slug":"matlab-tutorial-01-basic-operation-and-matrix-input","status":"publish","type":"post","link":"https:\/\/swordofmorning.com\/index.php\/2021\/06\/07\/matlab-tutorial-01-basic-operation-and-matrix-input\/","title":{"rendered":"Matlab Tutorial 01 Basic Operation and Matrix Input"},"content":{"rendered":"<p><div class=\"has-toc have-toc\"><\/div><\/p>\n<h2>\u4e00\u3001\u6570\u5b57\u663e\u793a\u683c\u5f0f<\/h2>\n<p>&nbsp;&nbsp;&nbsp;&nbsp;\u663e\u793a\u683c\u5f0f\u547d\u4ee4\u201cformat _Display_format<em>name<\/em>\u201d\uff0cformat name\u6709\u5982\u4e0b\uff1a<\/p>\n<ul>\n<li>short\uff1a4\u4f4d\u5c0f\u6570<\/li>\n<li>long\uff1a15\u4f4d\u5c0f\u6570<\/li>\n<li>shortE\uff1a4\u4f4d+\u79d1\u5b66<\/li>\n<li>longE\uff1a15\u4f4d+\u79d1\u5b66<\/li>\n<li>bank\uff1a2\u4f4d\u5c0f\u6570<\/li>\n<li>hex\uff1a16\u8fdb\u5236<\/li>\n<li>rat\uff1a\u5206\u6570<\/li>\n<\/ul>\n<h2>\u4e8c\u3001\u5c0f\u6280\u5de7\u51fd\u6570<\/h2>\n<ul>\n<li>clc\uff1a\u6e05\u9664\u547d\u4ee4\u7a97\u53e3<\/li>\n<li>clear\uff1a\u4eceworkspace\u4e2d\u79fb\u9664\u6240\u6709\u53d8\u91cf<\/li>\n<li>who\uff1aworkspace\u4e2d\u7684\u53d8\u91cf<\/li>\n<li>whos\uff1aworkspace\u4e2d\u7684\u53d8\u91cf\u7684\u4fe1\u606f<\/li>\n<\/ul>\n<h2>\u4e09\u3001\u77e9\u9635\u64cd\u4f5c<\/h2>\n<h3>3.1 \u8bbf\u95ee\u77e9\u9635\u4e2d\u7684\u67d0\u4e00\u4e2a\u5143\u7d20<\/h3>\n<pre><code>  A(col, row)<\/code><\/pre>\n<h3>3.2 \u8bbf\u95ee\u77e9\u9635\u90e8\u5206\u5143\u7d20<\/h3>\n<p>&nbsp;&nbsp;&nbsp;&nbsp;\u4e0b\u9762\u7ed9\u51fa\u4e00\u4e2a\u77e9\u9635A\uff1a<\/p>\n<pre><code>A = [\n1, 2, 3;\n4, 5, 6;\n7, 8, 9;\n]<\/code><\/pre>\n<p>&nbsp;&nbsp;&nbsp;&nbsp;\u77e9\u9635\u6309Index 1-9\u7d22\u5f15\u7ed3\u679c\u4e3a\uff1a1 4 7 2 5 8 3 6 9\uff0c\u6309col\u8fdb\u884c\u3002<\/p>\n<h4>3.2.1 A([1, 3; 1, 3])<\/h4>\n<pre><code> A([1 3; 1 3])\n\nans =\n\n     1     7\n     1     7<\/code><\/pre>\n<p>&nbsp;&nbsp;&nbsp;&nbsp;\u9009\u53d6\u51faA\u4e2d\u7684\u201c\u7b2c\u4e00\u4e2a\u4e0e\u7b2c\u4e09\u4e2a\u5143\u7d20\u201d \u548c \u201c\u7b2c\u4e00\u4e2a\u4e0e\u7b2c\u4e09\u4e2a\u5143\u7d20\u201d\u7ec4\u6210\u4e00\u4e2a\u77e9\u9635\u3002<\/p>\n<h4>3.2.2 A([1 3], [1 3])<\/h4>\n<pre><code>A([1 3], [1, 3])\n\nans =\n\n     1     3\n     7     9\n<\/code><\/pre>\n<p>&nbsp;&nbsp;&nbsp;&nbsp;\u5c06A\u4e2d\u7684\u7b2c1\u30013\u884c\u4e0e\u7b2c1\u30013\u5217\u6392\u5217\u7ec4\u5408\u7684\u5143\u7d20\u7ec4\u6210\u4e00\u4e2a\u77e9\u9635\u3002<\/p>\n<h3>3.3 \u5feb\u901f\u6784\u5efa\u7b49\u5dee\u5411\u91cf<\/h3>\n<pre><code>>&gt; a = [1 : 2 : 10]\n\na =\n\n     1     3     5     7     9<\/code><\/pre>\n<h3>3.4 \u8bfb\u53d6\u77e9\u9635\u7684\u67d0\u884c\u5217<\/h3>\n<pre><code>A =\n\n     1     2     3\n     4     5     6\n     7     8     9\n\n>&gt; A(3, :)\n\nans =\n\n     7     8     9\n\n>&gt; A(:, 1)\n\nans =\n\n     1\n     4\n     7<\/code><\/pre>\n<h3>3.5 \u5220\u9664\u77e9\u9635\u7684\u67d0\u884c\u5217<\/h3>\n<pre><code>A =\n\n     1     2     3\n     4     5     6\n     7     8     9\n\n>&gt; A(3, :) = []\n\nA =\n\n     1     2     3\n     4     5     6<\/code><\/pre>\n<h3>3.6 \u77e9\u9635\u62fc\u5408<\/h3>\n<pre><code>>&gt; A\n\nA =\n\n     1     2     3     4\n\n>&gt; B\n\nB =\n\n     6     7     8     9\n\n>&gt; F = [A, B]\n\nF =\n\n     1     2     3     4     6     7     8     9\n\n>&gt; F = [A; B]\n\nF =\n\n     1     2     3     4\n     6     7     8     9<\/code><\/pre>\n<h3>3.7 \u7279\u6b8a\u77e9\u9635<\/h3>\n<ul>\n<li>eye(n)\uff1an\u9636\u5355\u4f4d\u77e9\u9635<\/li>\n<li>zeors(n1, n2)\uff1an1*n2\u5927\u5c0f\u7684\u96f6\u77e9\u9635<\/li>\n<li>ones(n1, n2)\uff1an1*n2\u7684\u51681\u77e9\u9635<\/li>\n<li>diag(vector)\uff1a\u4ee5vector\u4e3a\u5143\u7d20\u521b\u5efa\u5bf9\u89d2\u77e9\u9635<\/li>\n<li>rand()\uff1a\u968f\u673a\u77e9\u9635<\/li>\n<\/ul>\n","protected":false},"excerpt":{"rendered":"<p>\u4e00\u3001\u6570\u5b57\u663e\u793a\u683c\u5f0f &nbsp;&nbsp;&nbsp;&nbsp;\u663e\u793a\u683c\u5f0f\u547d\u4ee4\u201cformat _Display_formatnam &#8230;<\/p>","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[65],"tags":[],"amp_enabled":true,"_links":{"self":[{"href":"https:\/\/swordofmorning.com\/index.php\/wp-json\/wp\/v2\/posts\/215"}],"collection":[{"href":"https:\/\/swordofmorning.com\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/swordofmorning.com\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/swordofmorning.com\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/swordofmorning.com\/index.php\/wp-json\/wp\/v2\/comments?post=215"}],"version-history":[{"count":1,"href":"https:\/\/swordofmorning.com\/index.php\/wp-json\/wp\/v2\/posts\/215\/revisions"}],"predecessor-version":[{"id":1039,"href":"https:\/\/swordofmorning.com\/index.php\/wp-json\/wp\/v2\/posts\/215\/revisions\/1039"}],"wp:attachment":[{"href":"https:\/\/swordofmorning.com\/index.php\/wp-json\/wp\/v2\/media?parent=215"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/swordofmorning.com\/index.php\/wp-json\/wp\/v2\/categories?post=215"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/swordofmorning.com\/index.php\/wp-json\/wp\/v2\/tags?post=215"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}