{"id":303172,"date":"2024-05-20T18:53:25","date_gmt":"2024-05-20T10:53:25","guid":{"rendered":"https:\/\/docs.pingcode.com\/ask\/ask-ask\/303172.html"},"modified":"2024-05-20T18:53:57","modified_gmt":"2024-05-20T10:53:57","slug":"%e5%87%bd%e6%95%b0size_acc%ef%bc%88matlab%ef%bc%89%e6%98%af%e5%ae%9e%e7%8e%b0%e4%bb%80%e4%b9%88%e5%8a%9f%e8%83%bd","status":"publish","type":"post","link":"https:\/\/docs.pingcode.com\/ask\/303172.html","title":{"rendered":"\u51fd\u6570size_acc\uff08MATLAB\uff09\u662f\u5b9e\u73b0\u4ec0\u4e48\u529f\u80fd"},"content":{"rendered":"<p style=\"text-align:center\"><img decoding=\"async\" src=\"https:\/\/cdn-kb.worktile.com\/kb\/wp-content\/uploads\/2024\/04\/26215441\/4a8a5f5a-1a0a-42eb-9ff8-7d472e8776ff.webp\" alt=\"\u51fd\u6570size_acc\uff08MATLAB\uff09\u662f\u5b9e\u73b0\u4ec0\u4e48\u529f\u80fd\" \/><\/p>\n<p><p>\u51fd\u6570<code>size_acc<\/code>\u5728MATLAB\u4e2d\u5e76\u4e0d\u662f\u4e00\u4e2a\u6807\u51c6\u7684\u5185\u7f6e\u51fd\u6570\u3002<strong>\u5982\u679c\u5b58\u5728\u8fd9\u6837\u547d\u540d\u7684\u51fd\u6570\uff0c\u5b83\u53ef\u80fd\u662f\u7528\u6237\u81ea\u5b9a\u4e49\u7684<\/strong>\u3001<strong>\u7528\u4e8e\u5b8c\u6210\u7279\u5b9a\u4efb\u52a1\u7684\u51fd\u6570<\/strong>\u3002\u4e00\u822c\u60c5\u51b5\u4e0b\uff0c\u51fd\u6570\u540d\u4e2d\u7684\u201csize\u201d\u53ef\u80fd\u8868\u793a\u5b83\u4e0e\u5c3a\u5bf8\u6216\u5927\u5c0f\u76f8\u5173\uff0c\u800c\u201cacc\u201d\u53ef\u80fd\u8868\u793a\u5b83\u6d89\u53ca\u5230\u7d2f\u52a0\uff08accumulation\uff09\u6216\u8005\u7cbe\u5ea6\uff08accuracy\uff09\u3002\u56e0\u6b64\uff0c\u6839\u636e\u547d\u540d\u63a8\u6d4b\uff0c<code>size_acc<\/code>\u53ef\u80fd\u662f\u4e00\u4e2a\u7528\u4e8e\u7d2f\u8ba1\u7edf\u8ba1\u6570\u7ec4\u4e2d\u5143\u7d20\u5c3a\u5bf8\u7684\u51fd\u6570\uff0c\u6216\u8005\u53ef\u80fd\u7528\u6765\u63d0\u9ad8\u6570\u636e\u5904\u7406\u7684\u7cbe\u5ea6\u3002\u7531\u4e8e\u8fd9\u4e0d\u662fMATLAB\u7684\u6807\u51c6\u51fd\u6570\uff0c\u5bf9\u5176\u8fdb\u884c\u8be6\u7ec6\u63cf\u8ff0\u9700\u8981\u67e5\u770b\u8be5\u51fd\u6570\u7684\u5177\u4f53\u5b9e\u73b0\u4ee3\u7801\u3002<\/p>\n<\/p>\n<p><p>\u4e00\u3001\u51fd\u6570<code>size_acc<\/code>\u7684\u53ef\u80fd\u529f\u80fd<\/p>\n<\/p>\n<p><p>\u5c3d\u7ba1<code>size_acc<\/code>\u4e0d\u662fMATLAB\u5185\u7f6e\u51fd\u6570\uff0c\u6211\u4eec\u53ef\u4ee5\u8003\u8651\u5b83\u53ef\u80fd\u7684\u529f\u80fd\u662f<strong>\u5bf9\u6570\u7ec4\u6216\u77e9\u9635\u5927\u5c0f\u8fdb\u884c\u7d2f\u79ef\u6027\u7684\u8ba1\u7b97\u5904\u7406<\/strong>\uff0c\u4f8b\u5982\u7edf\u8ba1\u77e9\u9635\u4e2d\u6bcf\u4e2a\u7ef4\u5ea6\u7684\u5143\u7d20\u4e2a\u6570\u5e76\u6309\u7167\u67d0\u79cd\u7b97\u6cd5\u7d2f\u52a0\u3002\u7528\u6237\u81ea\u5b9a\u4e49\u51fd\u6570\u53ef\u80fd\u6839\u636e\u7279\u5b9a\u7684\u8f93\u5165\u53c2\u6570\u5bf9\u8f93\u51fa\u7ed3\u679c\u8fdb\u884c\u7cbe\u7ec6\u63a7\u5236\uff0c\u4f8b\u5982\u8003\u8651\u6570\u636e\u7c7b\u578b\u3001\u5904\u7406\u7a7a\u77e9\u9635\u7684\u7279\u6b8a\u60c5\u51b5\u7b49\u3002<\/p>\n<\/p>\n<p><p>\u4e8c\u3001\u5982\u4f55\u4f7f\u7528MATLAB\u81ea\u5b9a\u4e49\u51fd\u6570<\/p>\n<\/p>\n<p><p>\u8981\u5728MATLAB\u4e2d\u5b9a\u4e49\u81ea\u5df1\u7684\u51fd\u6570\uff0c\u60a8\u9700\u8981\u521b\u5efa\u4e00\u4e2a\u65b0\u7684\u51fd\u6570\u6587\u4ef6\uff0c\u8be5\u6587\u4ef6\u4ee5<code>.m<\/code>\u7ed3\u5c3e\u3002\u4f8b\u5982\uff0c\u521b\u5efa\u4e00\u4e2a\u540d\u4e3a<code>size_acc.m<\/code>\u7684\u6587\u4ef6\u3002\u5728\u6587\u4ef6\u4e2d\uff0c\u60a8\u4f1a\u5b9a\u4e49\u51fd\u6570\u7684\u8f93\u5165\u3001\u8f93\u51fa\u548c\u6267\u884c\u7684\u5177\u4f53\u7b97\u6cd5\u3002\u4ee5\u4e0b\u662f\u4e00\u4e2a\u7b80\u5316\u7684\u81ea\u5b9a\u4e49\u51fd\u6570\u7684\u4f8b\u5b50\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-matlab\">function [output] = size_acc(input)<\/p>\n<p>    % \u5728\u8fd9\u91cc\u5b9e\u73b0size_acc\u7684\u8ba1\u7b97\u903b\u8f91<\/p>\n<p>end<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u5728\u8fd9\u4e2a\u865a\u6784\u7684<code>size_acc<\/code>\u51fd\u6570\u4e2d\uff0c<code>input<\/code>\u8868\u793a\u8f93\u5165\u53c2\u6570\uff0c\u800c<code>output<\/code>\u5219\u662f\u8981\u8fd4\u56de\u7684\u7ed3\u679c\u3002<\/p>\n<\/p>\n<p><p>\u4e09\u3001MATLAB\u4e2d\u5185\u7f6e\u7684\u4e0e\u5c3a\u5bf8\u6709\u5173\u7684\u51fd\u6570<\/p>\n<\/p>\n<p><p>\u5728MATLAB\u4e2d\uff0c\u4e0e\u5c3a\u5bf8\u76f8\u5173\u7684\u6807\u51c6\u51fd\u6570\u662f<code>size<\/code>\u3002<code>size<\/code>\u51fd\u6570\u7528\u4e8e\u8fd4\u56de\u6570\u7ec4\u7684\u5c3a\u5bf8\uff08\u6bd4\u5982\u884c\u6570\u548c\u5217\u6570\uff09\u3002\u5176\u57fa\u672c\u7528\u6cd5\u662f\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-matlab\">dims = size(A);<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u5176\u4e2d<code>A<\/code>\u662f\u4e00\u4e2a\u6570\u7ec4\uff0c<code>dims<\/code>\u5c06\u5305\u542b<code>A<\/code>\u7684\u5c3a\u5bf8\u4fe1\u606f\uff0c\u4f8b\u5982<code>[rows columns]<\/code>\u3002<\/p>\n<\/p>\n<p><p>\u56db\u3001\u5728MATLAB\u4e2d\u5904\u7406\u7d2f\u79ef\u548c\u7d2f\u52a0\u64cd\u4f5c<\/p>\n<\/p>\n<p><p>\u7d2f\u79ef\u548c\u7d2f\u52a0\u5728MATLAB\u4e2d\u901a\u5e38\u4f7f\u7528<code>cumsum<\/code>\u51fd\u6570\u6765\u5b9e\u73b0\uff0c\u8be5\u51fd\u6570\u8ba1\u7b97\u6cbf\u6570\u7ec4\u67d0\u4e00\u7ef4\u5ea6\u7684\u7d2f\u79ef\u548c\u3002\u8fd9\u79cd\u64cd\u4f5c\u53ef\u80fd\u662f<code>size_acc<\/code>\u51fd\u6570\u6240\u8981\u5b9e\u73b0\u7684\u529f\u80fd\u7684\u4e00\u90e8\u5206\u3002\u4f8b\u5982\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-matlab\">cumulativeSum = cumsum(A, dim);<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u6b64\u5904<code>A<\/code>\u662f\u9700\u8981\u8fdb\u884c\u7d2f\u79ef\u6c42\u548c\u7684\u6570\u7ec4\uff0c\u800c<code>dim<\/code>\u662f\u6307\u5b9a\u8981\u6cbf\u5176\u64cd\u4f5c\u7684\u7ef4\u5ea6\u3002\u5982\u679c\u6ca1\u6709\u6307\u5b9a<code>dim<\/code>\uff0c\u9ed8\u8ba4\u6cbf\u7b2c\u4e00\u7ef4\u5ea6\u8fdb\u884c\u8ba1\u7b97\u3002<\/p>\n<\/p>\n<p><p>\u7efc\u4e0a\u6240\u8ff0\uff0c\u4e86\u89e3\u51fd\u6570<code>size_acc<\/code>\u7684\u786e\u5207\u529f\u80fd\u9700\u8981\u68c0\u9605\u5176\u6e90\u4ee3\u7801\u3002\u7136\u800c\uff0c\u63a8\u6d4b\u5b83\u53ef\u80fd\u4e0e\u6570\u7ec4\u7684\u5c3a\u5bf8\u8ba1\u7b97\u6216\u8005\u6570\u636e\u7d2f\u52a0\u6709\u5173\uff0c\u6d89\u53ca\u5230\u7c7b\u4f3c<code>size<\/code>\u6216<code>cumsum<\/code>\u8fd9\u6837\u7684\u64cd\u4f5c\u3002\u5bf9\u4e8e\u7528\u6237\u81ea\u5b9a\u4e49\u51fd\u6570\uff0c\u7406\u89e3\u5176\u5b9e\u73b0\u539f\u7406\u662f\u4f7f\u7528\u8be5\u51fd\u6570\u5e76\u6269\u5c55\u5176\u529f\u80fd\u7684\u5173\u952e\u3002<\/p>\n<\/p>\n<h2><strong>\u76f8\u5173\u95ee\u7b54FAQs\uff1a<\/strong><\/h2>\n<p><strong>1. \u5982\u4f55\u4f7f\u7528MATLAB\u4e2d\u7684\u51fd\u6570size_acc\uff1f<\/strong><\/p>\n<p>MATLAB\u4e2d\u7684\u51fd\u6570size_acc\u4e3b\u8981\u7528\u4e8e\u8ba1\u7b97\u77e9\u9635\u7684\u5c3a\u5bf8\u6216\u6570\u7ec4\u7684\u5927\u5c0f\u3002\u5b83\u53ef\u4ee5\u8fd4\u56de\u77e9\u9635\u6216\u6570\u7ec4\u7684\u884c\u6570\u548c\u5217\u6570\uff0c\u6216\u8005\u8fd4\u56de\u77e9\u9635\u6216\u6570\u7ec4\u7684\u603b\u5143\u7d20\u4e2a\u6570\u3002\u60a8\u53ef\u4ee5\u901a\u8fc7\u8f93\u5165\u53c2\u6570\u6765\u6307\u5b9a\u8981\u8ba1\u7b97\u5c3a\u5bf8\u7684\u77e9\u9635\u6216\u6570\u7ec4\uff0c\u7136\u540e\u51fd\u6570\u4f1a\u8fd4\u56de\u76f8\u5e94\u7684\u5c3a\u5bf8\u4fe1\u606f\u3002<\/p>\n<p><strong>2. \u5982\u4f55\u5229\u7528MATLAB\u4e2d\u7684\u51fd\u6570size_acc\u6765\u786e\u5b9a\u6570\u636e\u96c6\u7684\u7ef4\u6570\uff1f<\/strong><\/p>\n<p>\u8981\u786e\u5b9a\u6570\u636e\u96c6\u7684\u7ef4\u6570\uff0c\u60a8\u53ef\u4ee5\u4f7f\u7528MATLAB\u4e2d\u7684\u51fd\u6570size_acc\u3002\u901a\u8fc7\u5c06\u6570\u636e\u96c6\u4f5c\u4e3a\u8f93\u5165\u53c2\u6570\u4f20\u9012\u7ed9\u51fd\u6570\uff0c\u5b83\u5c06\u8fd4\u56de\u6570\u636e\u96c6\u7684\u5c3a\u5bf8\u4fe1\u606f\u3002\u5982\u679c\u8fd4\u56de\u7ed3\u679c\u4e2d\u53ea\u6709\u4e00\u4e2a\u503c\uff0c\u5219\u8868\u793a\u6570\u636e\u96c6\u662f\u4e00\u7ef4\u7684\uff1b\u5982\u679c\u8fd4\u56de\u7ed3\u679c\u4e2d\u6709\u4e24\u4e2a\u503c\uff0c\u5219\u8868\u793a\u6570\u636e\u96c6\u662f\u4e8c\u7ef4\u7684\uff1b\u5982\u679c\u8fd4\u56de\u7ed3\u679c\u4e2d\u6709\u4e09\u4e2a\u503c\uff0c\u5219\u8868\u793a\u6570\u636e\u96c6\u662f\u4e09\u7ef4\u7684\uff0c\u4f9d\u6b64\u7c7b\u63a8\u3002<\/p>\n<p><strong>3. \u5982\u4f55\u5728MATLAB\u4e2d\u4f7f\u7528size_acc\u51fd\u6570\u6765\u67e5\u770b\u56fe\u50cf\u7684\u5206\u8fa8\u7387\uff1f<\/strong><\/p>\n<p>\u8981\u67e5\u770b\u56fe\u50cf\u7684\u5206\u8fa8\u7387\uff0c\u60a8\u53ef\u4ee5\u4f7f\u7528MATLAB\u4e2d\u7684\u51fd\u6570size_acc\u3002\u9996\u5148\uff0c\u5c06\u56fe\u50cf\u52a0\u8f7d\u5230MATLAB\u73af\u5883\u4e2d\uff0c\u7136\u540e\u5c06\u5176\u4f5c\u4e3a\u8f93\u5165\u53c2\u6570\u4f20\u9012\u7ed9size_acc\u51fd\u6570\u3002\u51fd\u6570\u5c06\u8fd4\u56de\u56fe\u50cf\u7684\u5c3a\u5bf8\u4fe1\u606f\uff0c\u5176\u4e2d\u5305\u62ec\u56fe\u50cf\u7684\u5bbd\u5ea6\u548c\u9ad8\u5ea6\u3002\u8fd9\u4e9b\u503c\u5c06\u5e2e\u52a9\u60a8\u786e\u5b9a\u56fe\u50cf\u7684\u5206\u8fa8\u7387\uff0c\u4ee5\u4fbf\u8fdb\u884c\u8fdb\u4e00\u6b65\u7684\u5904\u7406\u6216\u5206\u6790\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"\u51fd\u6570size_acc\u5728MATLAB\u4e2d\u5e76\u4e0d\u662f\u4e00\u4e2a\u6807\u51c6\u7684\u5185\u7f6e\u51fd\u6570\u3002\u5982\u679c\u5b58\u5728\u8fd9\u6837\u547d\u540d\u7684\u51fd\u6570\uff0c\u5b83\u53ef\u80fd\u662f\u7528\u6237\u81ea\u5b9a\u4e49\u7684\u3001\u7528 [&hellip;]","protected":false},"author":3,"featured_media":303213,"comment_status":"closed","ping_status":"","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[37],"tags":[],"acf":[],"_links":{"self":[{"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/posts\/303172"}],"collection":[{"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/users\/3"}],"replies":[{"embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/comments?post=303172"}],"version-history":[{"count":0,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/posts\/303172\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/media\/303213"}],"wp:attachment":[{"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/media?parent=303172"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/categories?post=303172"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/tags?post=303172"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}