{"id":4194,"date":"2021-10-04T18:32:22","date_gmt":"2021-10-04T09:32:22","guid":{"rendered":"https:\/\/blogs.mathworks.com\/japan-community\/?p=4194"},"modified":"2021-10-04T18:32:22","modified_gmt":"2021-10-04T09:32:22","slug":"matlab_system_block","status":"publish","type":"post","link":"https:\/\/blogs.mathworks.com\/japan-community\/2021\/10\/04\/matlab_system_block\/","title":{"rendered":"\u3061\u3087\u3063\u3068\u9ad8\u5ea6\u306a\u30ab\u30b9\u30bf\u30e0\u30d6\u30ed\u30c3\u30af\u3001\u300cMATLAB System \u30d6\u30ed\u30c3\u30af\u300d\u3092\u4f7f\u3044\u3053\u306a\u305b\uff01"},"content":{"rendered":"<p>\u7686\u3055\u3093\u3053\u3093\u306b\u3061\u306f\u3002\u30c8\u30ec\u30fc\u30cb\u30f3\u30b0\u30a8\u30f3\u30b8\u30cb\u30a2\u306e\u9060\u85e4\u3068\u7533\u3057\u307e\u3059\u3002<br \/>\n\u3053\u306e\u30d6\u30ed\u30b0\u3067\u306f\u3001\u300cSimulink \u3068 MATLAB \u3092\u3064\u306a\u3050\u300d\u3092\u30b3\u30f3\u30bb\u30d7\u30c8\u3068\u3057\u3066\u3001\u4e3b\u306b\u6280\u8853\u7684\u306a\u5185\u5bb9\u306b\u3064\u3044\u3066\u66f8\u3044\u3066\u3044\u307e\u3059\u3002<\/p>\n<p>\u5148\u65e5\u3064\u3044\u306b MATLAB R2021b \u304c\u30ea\u30ea\u30fc\u30b9\u3055\u308c\u307e\u3057\u305f\u306d\uff01Simulink \u3068 MATLAB \u3092\u3064\u306a\u3050\u3088\u3046\u306a\u65b0\u6a5f\u80fd\u3082\u3042\u308b\u3088\u3046\u3067\u3001\u4eca\u56de\u306e\u30d6\u30ed\u30b0\u8a18\u4e8b\u3067\u3082\u305d\u308c\u306b\u3064\u3044\u3066\u66f8\u3053\u3046\u304b\u306a\u3068\u3082\u8003\u3048\u305f\u306e\u3067\u3059\u304c\u3001\u3055\u3059\u304c\u306b\u3082\u3046\u5c11\u3057\u81ea\u5206\u3067\u4f7f\u3063\u3066\u304b\u3089\u7d39\u4ecb\u3057\u305f\u3044\u306a\u3068\u3044\u3046\u90e8\u5206\u304c\u3042\u308a\u3001\u65b0\u6a5f\u80fd\u7d39\u4ecb\u306f\u307e\u305f\u6b21\u306e\u6a5f\u4f1a\u306b\u3057\u3088\u3046\u304b\u306a\u3068\u601d\u3044\u307e\u3059\u3002<\/p>\n<p>\u3068\u3044\u3046\u3053\u3068\u3067\u3001\u4eca\u56de\u306f\u300c<a href=\"https:\/\/jp.mathworks.com\/help\/simulink\/ug\/what-is-matlab-system-block.html\">MATLAB System \u30d6\u30ed\u30c3\u30af<\/a>\u300d\u306b\u30d5\u30a9\u30fc\u30ab\u30b9\u3092\u5f53\u3066\u3066\u3044\u304d\u305f\u3044\u3068\u601d\u3044\u307e\u3059\u3002Simulink \u3067 MATLAB \u30b3\u30fc\u30c9\u3092\u4f7f\u3046\u6a5f\u80fd\u3068\u3057\u3066\u306f\u3001<a href=\"https:\/\/blogs.mathworks.com\/japan-community\/2021\/04\/15\/matlab-function-block\/?from=jp\">\u4ee5\u524d\u306e\u30d6\u30ed\u30b0\u8a18\u4e8b<\/a>\u3067\u3082\u7d39\u4ecb\u3057\u305f\u300c<a href=\"https:\/\/jp.mathworks.com\/help\/simulink\/slref\/matlabfunction.html\">MATLAB Function \u30d6\u30ed\u30c3\u30af<\/a>\u300d\u304c\u6709\u540d\u3067\u3001MATLAB System \u30d6\u30ed\u30c3\u30af\u306f\u5c11\u3057\u30de\u30a4\u30ca\u30fc\u306a\u90e8\u985e\u306b\u5165\u308b\u304b\u3068\u601d\u3044\u307e\u3059\u3002\u3057\u304b\u3057\u3001\u5b9f\u88c5\u3057\u305f\u3044\u51e6\u7406\u306b\u3088\u3063\u3066\u306f MATLAB System \u30d6\u30ed\u30c3\u30af\u306e\u65b9\u304c\u9069\u3057\u3066\u3044\u308b\u5834\u9762\u3082\u5c11\u306a\u304f\u3042\u308a\u307e\u305b\u3093\u3002<\/p>\n<p>\u7279\u306b\u3001\u4ee5\u4e0b\u306e\u3088\u3046\u306a\u65b9\u306f MATLAB System \u30d6\u30ed\u30c3\u30af\u3092\u4f7f\u3044\u3053\u306a\u3059\u3053\u3068\u3067\u3088\u308a\u52b9\u7387\u7684\u306b\u30e2\u30c7\u30eb\u3092\u4f5c\u308c\u308b\u3088\u3046\u306b\u306a\u308b\u304b\u3082\u3057\u308c\u307e\u305b\u3093\u306e\u3067\u3001\u5fc5\u898b\u3067\u3059\uff01<\/p>\n<ul>\n<li>MATLAB Function \u30d6\u30ed\u30c3\u30af\u3067\u6c38\u7d9a\u5909\u6570\u3092\u3088\u304f\u4f7f\u3046<\/li>\n<li>MATLAB Function \u30d6\u30ed\u30c3\u30af\u5185\u3067\u30b3\u30fc\u30c9\u751f\u6210\u5bfe\u5fdc\u5916\u306e\u95a2\u6570\u3092\u4f7f\u3046\u6a5f\u4f1a\u304c\u591a\u3044<\/li>\n<li>MATLAB Function \u30d6\u30ed\u30c3\u30af\u306e\u30b3\u30fc\u30c9\u5185\u306e\u30d1\u30e9\u30e1\u30fc\u30bf\u3092\u8abf\u6574\u3059\u308b\u3053\u3068\u304c\u591a\u3044<\/li>\n<\/ul>\n<h2>\u76ee\u6b21\uff1a<\/h2>\n<ol>\n<li><a href=\"#first\">MATLAB System \u30d6\u30ed\u30c3\u30af\u3068\u306f\uff1f<\/a><\/li>\n<li><a href=\"#second\">MATLAB System \u30d6\u30ed\u30c3\u30af\u306e\u30e1\u30ea\u30c3\u30c8<\/a>\n<ol>\n<li><a href=\"#second1\">\u30d6\u30ed\u30c3\u30af\u30c0\u30a4\u30a2\u30ed\u30b0\u304b\u3089\u30d1\u30e9\u30e1\u30fc\u30bf\u3092\u8a2d\u5b9a\u3067\u304d\u308b<\/a><\/li>\n<li><a href=\"#second2\">\u5185\u90e8\u72b6\u614b\u3092\u6301\u3064\u3053\u3068\u304c\u3067\u304d\u308b<\/a><\/li>\n<li><a href=\"#second3\">\u30b7\u30df\u30e5\u30ec\u30fc\u30b7\u30e7\u30f3\u958b\u59cb\u6642\u306b\uff11\u5ea6\u3060\u3051\u5b9f\u884c\u3057\u305f\u3044\u51e6\u7406\u3092\u7c21\u5358\u306b\u5b9f\u88c5\u3067\u304d\u308b<\/a><\/li>\n<li><a href=\"#second4\">\u30b3\u30fc\u30c9\u751f\u6210\u306b\u5bfe\u5fdc\u3057\u3066\u3044\u306a\u3044\u95a2\u6570\u3082\u305d\u306e\u307e\u307e\u4f7f\u7528\u53ef\u80fd<\/a><\/li>\n<\/ol>\n<\/li>\n<li><a href=\"#third\">\u304a\u308f\u308a\u306b<\/a><\/li>\n<\/ol>\n<p>&nbsp;<\/p>\n<h1 id=\"first\"><span style=\"color: #ff6600\">MATLAB System \u30d6\u30ed\u30c3\u30af\u3068\u306f\uff1f<\/span><\/h1>\n<p>\u307e\u305a\u306f MATLAB System \u30d6\u30ed\u30c3\u30af\u306b\u3064\u3044\u3066\u7c21\u5358\u306b\u8aac\u660e\u3057\u305f\u3044\u3068\u601d\u3044\u307e\u3059\u3002MATLAB System \u30d6\u30ed\u30c3\u30af\u306f\u3001<a href=\"https:\/\/jp.mathworks.com\/help\/matlab\/matlab_prog\/what-are-system-objects.html\">System object<\/a> \u3092\u7528\u3044\u3066\u52d5\u4f5c\u3092\u30ab\u30b9\u30bf\u30de\u30a4\u30ba\u3067\u304d\u308b\u30d6\u30ed\u30c3\u30af\u3067\u3059\u3002System object \u306f\u3042\u307e\u308a\u99b4\u67d3\u307f\u306e\u306a\u3044\u65b9\u3082\u3044\u308b\u304b\u3082\u3057\u308c\u307e\u305b\u3093\u304c\u3001\u7c21\u5358\u306b\u8a00\u3046\u3068\u30b7\u30df\u30e5\u30ec\u30fc\u30b7\u30e7\u30f3\u3084\u30b9\u30c8\u30ea\u30fc\u30df\u30f3\u30b0\u51e6\u7406\u7528\u306b\u3064\u304f\u3089\u308c\u305f\u3001\u5909\u6570\u3084\u95a2\u6570\u3092\u5185\u90e8\u306b\u6301\u3064\u3053\u3068\u306e\u3067\u304d\u308b\u30aa\u30d6\u30b8\u30a7\u30af\u30c8\u3067\u3059\uff08\u8a73\u3057\u304f\u77e5\u308a\u305f\u3044\u65b9\u306f\u30ea\u30f3\u30af\u5148\u306e\u30c9\u30ad\u30e5\u30e1\u30f3\u30c8\u3092\u53c2\u7167\u304f\u3060\u3055\u3044\uff09\u3002<\/p>\n<p>\u5b9f\u969b\u306b MATLAB System \u30d6\u30ed\u30c3\u30af\u3092\u4f7f\u3063\u3066\u307f\u307e\u3057\u3087\u3046\u3002\u307e\u305a\u306f\u30e2\u30c7\u30eb\u4e0a\u306b MATLAB System \u30d6\u30ed\u30c3\u30af\u3092\u7f6e\u3044\u3066\u307f\u307e\u3059\u3002<\/p>\n<p><img decoding=\"async\" loading=\"lazy\" width=\"980\" height=\"746\" class=\"alignnone size-full wp-image-4200\" src=\"https:\/\/blogs.mathworks.com\/japan-community\/files\/2021\/09\/blockDialog.png\" alt=\"\" \/><\/p>\n<p>\u6700\u521d\u306f System object \u304c\u4f55\u3082\u7d10\u3065\u3044\u3066\u3044\u306a\u3044\u306e\u3067\u8d64\u3044\u30a8\u30e9\u30fc\u304c\u8868\u793a\u3055\u308c\u3066\u3044\u307e\u3059\u3002\u30c0\u30d6\u30eb\u30af\u30ea\u30c3\u30af\u3057\u3066\u30d6\u30ed\u30c3\u30af\u30c0\u30a4\u30a2\u30ed\u30b0\u3092\u958b\u304f\u3068\u3001\u65e2\u5b58\u306e System object \u3092\u6307\u5b9a\u3001\u307e\u305f\u306f\u65b0\u898f\u3067 System object \u3092\u4f5c\u6210\u3059\u308b\u3053\u3068\u304c\u3067\u304d\u307e\u3059\u3002\u65b0\u898f\u4f5c\u6210\u306e\u969b\u306b\u306f\u300c\u6a19\u6e96\u300d\u300c\u8a73\u7d30\u8a2d\u5b9a\u300d\u300cSimulink \u62e1\u5f35\u300d\u306e\uff13\u3064\u306e\u30c6\u30f3\u30d7\u30ec\u30fc\u30c8\u304b\u3089\u4f5c\u6210\u3059\u308b\u3053\u3068\u304c\u3067\u304d\u307e\u3059\u304c\u3001\u3053\u306e\u8a18\u4e8b\u3067\u306f\u4e00\u756a\u7c21\u5358\u306a\u300c\u6a19\u6e96\u300d\u30c6\u30f3\u30d7\u30ec\u30fc\u30c8\u306e\u4f7f\u3044\u65b9\u3092\u8aac\u660e\u3057\u3066\u3044\u304d\u305f\u3044\u3068\u601d\u3044\u307e\u3059\u3002<\/p>\n<p><img decoding=\"async\" loading=\"lazy\" width=\"1920\" height=\"1020\" class=\"alignnone size-full wp-image-4203\" src=\"https:\/\/blogs.mathworks.com\/japan-community\/files\/2021\/09\/templete.png\" alt=\"\" \/><\/p>\n<p>\u6a19\u6e96\u30c6\u30f3\u30d7\u30ec\u30fc\u30c8\u306e\u30b3\u30fc\u30c9\u304c\u81ea\u52d5\u3067\u958b\u304d\u307e\u3057\u305f\u3002MATLAB Function \u30d6\u30ed\u30c3\u30af\u306e\u95a2\u6570\u306b\u6bd4\u3079\u308b\u3068\u5c11\u3057\u8907\u96d1\u3067\u62b5\u6297\u611f\u3092\u611f\u3058\u308b\u65b9\u3082\u3044\u308b\u304b\u3082\u3057\u308c\u307e\u305b\u3093\u304c\u3001\uff11\u3064\uff11\u3064\u306e\u5f79\u5272\u3055\u3048\u899a\u3048\u3066\u3057\u307e\u3048\u3070\u305d\u3053\u307e\u3067\u96e3\u3057\u304f\u306f\u3042\u308a\u307e\u305b\u3093\u3001<\/p>\n<p>\u307e\u305a\u6700\u3082\u91cd\u8981\u306a\u306e\u304c\u3001\u30c6\u30f3\u30d7\u30ec\u30fc\u30c8\u30b3\u30fc\u30c9\u306e\u4e0b\u90e8\u306b\u3042\u308b stepImpl \u95a2\u6570\u3067\u3059\u3002\u3053\u306e\u95a2\u6570\u306f\u3001\u5404\u30bf\u30a4\u30e0\u30b9\u30c6\u30c3\u30d7\u3067 MATLAB System \u30d6\u30ed\u30c3\u30af\u306e\u51fa\u529b\u3092\u8a08\u7b97\u3059\u308b\u969b\u306b\u5b9f\u884c\u3055\u308c\u308b\u95a2\u6570\u3067\u3059\u3002MATLAB Function \u30d6\u30ed\u30c3\u30af\u3067\u4f5c\u308b\u95a2\u6570\u3068\u57fa\u672c\u7684\u306b\u306f\u540c\u3058\u5f79\u5272\u3067\u3059\u306d\u3002\u3053\u306e\u95a2\u6570\u306e\u4e2d\u306b\u51fa\u529b\u306e\u8a08\u7b97\u51e6\u7406\u3092\u66f8\u3044\u3066\u3044\u304d\u307e\u3059\u3002<\/p>\n<p><code><span style=\"color: #0000ff\">function<\/span> y = stepImpl(obj,u)<br \/>\n<span style=\"color: #339966\">% Implement algorithm. Calculate y as a function of input u and<\/span><span style=\"color: #339966\"><br \/>\n% discrete states.<br \/>\n<\/span>\u00a0 y = 2*u; <span style=\"color: #339966\">% \u5165\u529b\u3092 2 \u500d\u3057\u3066\u51fa\u529b\u3059\u308b<\/span><br \/>\n<span style=\"color: #0000ff\">end<\/span><\/code><\/p>\n<p>\u305d\u306e\u4ed6\u3001MATLAB Function \u30d6\u30ed\u30c3\u30af\u3068\u306f\u9055\u3044\u3001\u4ee5\u4e0b\u306e\u3088\u3046\u306a\u3082\u306e\u3082\u30c6\u30f3\u30d7\u30ec\u30fc\u30c8\u306b\u7528\u610f\u3055\u308c\u3066\u3044\u307e\u3059\u3002<\/p>\n<ul>\n<li>properties<br \/>\n\u3053\u3053\u3067\u306f\u30d6\u30ed\u30c3\u30af\u30c0\u30a4\u30a2\u30ed\u30b0\u304b\u3089\u5909\u66f4\u3067\u304d\u308b\u5909\u6570\u3092\u5b9a\u7fa9\u3059\u308b\u3053\u3068\u304c\u3067\u304d\u307e\u3059\uff08\u5f8c\u8ff0\uff09\u3002<\/li>\n<li>properties(DiscreteState)<br \/>\n\u3053\u3053\u3067\u306f\u96e2\u6563\u72b6\u614b\u7528\u306e\u5909\u6570\u3092\u5b9a\u7fa9\u3067\u304d\u307e\u3059\u3002\u5c11\u3057\u4e0a\u7d1a\u8005\u5411\u3051\u3067\u3059\u306e\u3067\u3053\u306e\u8a18\u4e8b\u3067\u306f\u8aac\u660e\u306f\u5272\u611b\u3057\u307e\u3059\u304c\u3001\u8a73\u3057\u304f\u77e5\u308a\u305f\u3044\u65b9\u306f<a href=\"https:\/\/jp.mathworks.com\/help\/matlab\/matlab_prog\/define-property-attributes-1.html\">\u3053\u3061\u3089\u306e\u30c9\u30ad\u30e5\u30e1\u30f3\u30c8<\/a>\u3092\u3054\u78ba\u8a8d\u304f\u3060\u3055\u3044\u3002<\/li>\n<li>properties(Access = private)<br \/>\n\u3053\u3053\u3067\u306f System Object \u306e\u95a2\u6570\u5185\u304b\u3089\u5024\u3092\u5909\u66f4\u53ef\u80fd\u306a\u5909\u6570\u3092\u5b9a\u7fa9\u3059\u308b\u3053\u3068\u304c\u3067\u304d\u307e\u3059\uff08\u5f8c\u8ff0\uff09\u3002<\/li>\n<li>setupImpl \u95a2\u6570<br \/>\n\u30b7\u30df\u30e5\u30ec\u30fc\u30b7\u30e7\u30f3\u958b\u59cb\u6642\u306b\uff11\u5ea6\u3060\u3051\u5b9f\u884c\u3055\u308c\u308b\u95a2\u6570\u3067\u3059\u3002\u5909\u6570\u306e\u8aad\u307f\u8fbc\u307f\u306a\u3069\uff11\u5ea6\u3060\u3051\u5b9f\u884c\u3059\u308c\u3070\u3088\u3044\u51e6\u7406\u306f\u3053\u3053\u306b\u8a18\u8f09\u3057\u307e\u3059\u3002<\/li>\n<li>resetImpl \u95a2\u6570<br \/>\nDiscreteState \u5c5e\u6027\u306e\u30d7\u30ed\u30d1\u30c6\u30a3\u3092\u521d\u671f\u5316\u3001\u30ea\u30bb\u30c3\u30c8\u3059\u308b\u305f\u3081\u306e\u95a2\u6570\u3067\u3059\u3002DiscreteState \u3092\u4f7f\u3063\u3066\u3044\u306a\u3044\u5834\u5408\u306f\u7279\u306b\u4f55\u3082\u66f8\u304f\u5fc5\u8981\u306f\u3042\u308a\u307e\u305b\u3093\u3002<\/li>\n<\/ul>\n<p>\u3053\u308c\u3089\u3092\u3046\u307e\u304f\u4f7f\u3046\u3068\u3001MATLAB Function \u30d6\u30ed\u30c3\u30af\u3067\u5b9f\u88c5\u3059\u308b\u306e\u304c\u9762\u5012\u81ed\u3044\u51e6\u7406\u3001\u96e3\u3057\u3044\u51e6\u7406\u3092\u7c21\u5358\u306b\u5b9f\u88c5\u3059\u308b\u3053\u3068\u304c\u3067\u304d\u307e\u3059\u3002\u65e9\u901f MATLAB System \u30d6\u30ed\u30c3\u30af\u306e\u30e1\u30ea\u30c3\u30c8\u3092\u5177\u4f53\u7684\u306b\u898b\u3066\u3044\u304d\u307e\u3057\u3087\u3046\u3002<\/p>\n<h1 id=\"second\"><span style=\"color: #ff6600\">MATLAB System \u30d6\u30ed\u30c3\u30af\u306e\u30e1\u30ea\u30c3\u30c8<\/span><\/h1>\n<p>&nbsp;<\/p>\n<h2 id=\"second1\"><span style=\"color: #ff6600\">1. \u30d6\u30ed\u30c3\u30af\u30c0\u30a4\u30a2\u30ed\u30b0\u304b\u3089\u30d1\u30e9\u30e1\u30fc\u30bf\u3092\u8a2d\u5b9a\u3067\u304d\u308b<\/span><\/h2>\n<p>MATLAB System \u30d6\u30ed\u30c3\u30af\u306f\u3001\u30b3\u30fc\u30c9\u5185\u3067\u4f7f\u7528\u3059\u308b\u30d1\u30e9\u30e1\u30fc\u30bf\u306e\u5024\u3092\u30d6\u30ed\u30c3\u30af\u30c0\u30a4\u30a2\u30ed\u30b0\u304b\u3089\u8a2d\u5b9a\u3059\u308b\u3053\u3068\u304c\u3067\u304d\u307e\u3059\u3002<\/p>\n<p>\u3084\u308a\u65b9\u306f\u3068\u3066\u3082\u7c21\u5358\u3001\u8a2d\u5b9a\u3057\u305f\u3044\u30d1\u30e9\u30e1\u30fc\u30bf\u3092 properties \u306e\u90e8\u5206\u3067\u5b9a\u7fa9\u3059\u308b\u3060\u3051\u3067\u3059\u3002<\/p>\n<p><code><span style=\"color: #0000ff\">properties<\/span><br \/>\n  k = 10; <span style=\"color: #339966\">% \u30d1\u30e9\u30e1\u30fc\u30bf\u7528\u306e\u5909\u6570\u3092\u5b9a\u7fa9<\/span><br \/>\n<span style=\"color: #0000ff\">end<\/span><\/code><\/p>\n<p>\u3053\u306e\u3088\u3046\u306b\u3001properties \u3067\u5909\u6570\u3092\u5b9a\u7fa9\u3059\u308b\u3068\u3001MATLAB System \u30d6\u30ed\u30c3\u30af\u3092\u30c0\u30d6\u30eb\u30af\u30ea\u30c3\u30af\u3057\u305f\u3068\u304d\u306b\u958b\u304f\u30c0\u30a4\u30a2\u30ed\u30b0\u306b\u3053\u306e\u5909\u6570\u304c\u8868\u793a\u3055\u308c\u3001\u5024\u304c\u5909\u66f4\u3067\u304d\u308b\u3088\u3046\u306b\u306a\u308a\u307e\u3059\u3002<\/p>\n<p><img decoding=\"async\" loading=\"lazy\" width=\"980\" height=\"746\" class=\"alignnone size-full wp-image-4218\" src=\"https:\/\/blogs.mathworks.com\/japan-community\/files\/2021\/09\/dialog.png\" alt=\"\" \/><\/p>\n<p>Gain \u30d6\u30ed\u30c3\u30af\u306a\u3069\u3068\u540c\u69d8\u3001\u30a8\u30c7\u30a3\u30c3\u30c8\u30dc\u30c3\u30af\u30b9\u3067\u5909\u6570\u540d\u3092\u6307\u5b9a\u3059\u308c\u3070\u3001MATLAB \u306e\u30ef\u30fc\u30af\u30b9\u30da\u30fc\u30b9\u4e0a\u306e\u5909\u6570\u306e\u5024\u3092\u4f7f\u3046\u3053\u3068\u3082\u3067\u304d\u307e\u3059\u3002<\/p>\n<p>\u305f\u3060\u3057\u3001\u3053\u306e\u5909\u6570\u3092\u30b3\u30fc\u30c9\u5185\u3067\u4f7f\u7528\u3059\u308b\u5834\u5408\u3001\u30b3\u30fc\u30c9\u306e\u66f8\u304d\u65b9\u306b\u6ce8\u610f\u304c\u5fc5\u8981\u3067\u3059\u3002properties \u306b\u5b9a\u7fa9\u3057\u305f\u5909\u6570\u306f\u3001\u5909\u6570\u540d\u3060\u3051\u3067\u306f\u30a2\u30af\u30bb\u30b9\u3067\u304d\u307e\u305b\u3093\u3002&#8221;obj.\u5909\u6570\u540d&#8221; \u3068\u3044\u3046\u8868\u8a18\u304c\u5fc5\u8981\u3067\u3059\u3002<\/p>\n<p><code><span style=\"color: #0000ff\">function<\/span> y = stepImpl(obj,u)<br \/>\n<span style=\"color: #339966\">% Implement algorithm. Calculate y as a function of input u and<\/span><span style=\"color: #339966\"><br \/>\n% discrete states.<\/span><br \/>\n  y = obj.k * u; <span style=\"color: #339966\">% obj.k \u3068\u3044\u3046\u8868\u8a18\u3067\u3001\u5b9a\u7fa9\u3057\u305f\u30d1\u30e9\u30e1\u30fc\u30bf k \u306b\u30a2\u30af\u30bb\u30b9<\/span><br \/>\n<span style=\"color: #0000ff\">end<\/span><\/code><\/p>\n<p>\u307e\u305f\u3001properties \u306b\u5b9a\u7fa9\u3057\u305f\u5909\u6570\u306e\u5024\u306f\u30b3\u30fc\u30c9\u4e2d\u3067\u5909\u66f4\u3067\u304d\u306a\u3044\u70b9\u306b\u3082\u6ce8\u610f\u3067\u3059\u3002<\/p>\n<h2 id=\"second2\"><span style=\"color: #ff6600\">2. \u5185\u90e8\u72b6\u614b\u3092\u6301\u3064\u3053\u3068\u304c\u3067\u304d\u308b<\/span><\/h2>\n<p>\u30d6\u30ed\u30c3\u30af\u306e\u51e6\u7406\u3092 MATLAB \u306e\u30b3\u30fc\u30c9\u3067\u5b9f\u88c5\u3057\u3066\u3044\u308b\u3068\u3001\u300c\u5909\u6570\u306e\u5024\u3092\u6b21\u306e\u30bf\u30a4\u30e0\u30b9\u30c6\u30c3\u30d7\u306e\u8a08\u7b97\u306b\u4f7f\u3046\u305f\u3081\u306b\u6b8b\u3057\u3066\u304a\u304d\u305f\u3044\u300d\u3068\u3044\u3046\u72b6\u6cc1\u306b\u3057\u3070\u3057\u3070\u906d\u9047\u3057\u307e\u3059\u3002MATLAB Function \u30d6\u30ed\u30c3\u30af\u3067\u306f\u300c\u6c38\u7d9a\u5909\u6570\u300d\u3092\u4f7f\u3046\u3053\u3068\u3067\u5909\u6570\u306e\u5024\u304c\u30ea\u30bb\u30c3\u30c8\u3055\u308c\u308b\u306e\u3092\u9632\u3050\u3053\u3068\u304c\u3067\u304d\u307e\u3059\u304c\u3001\u30b7\u30df\u30e5\u30ec\u30fc\u30b7\u30e7\u30f3\u5f8c\u306b Clear \u3059\u308b\u5fc5\u8981\u304c\u3042\u308b\u3001\u6761\u4ef6\u5206\u5c90\u306a\u3069\u306e\u8ffd\u52a0\u30b3\u30fc\u30c9\u304c\u5fc5\u8981\u306b\u306a\u308a\u30b3\u30fc\u30c9\u304c\u898b\u3065\u3089\u304f\u306a\u308b\u3001\u3068\u3044\u3063\u305f\u70b9\u3067\u5c11\u3057\u4f7f\u3044\u3065\u3089\u3044\u3067\u3059\u3002\u3053\u308c\u306b\u5bfe\u3057\u3001MATLAB System \u30d6\u30ed\u30c3\u30af\u3067\u306f\u3001properties(Access = private) \u3092\u4f7f\u3046\u3053\u3068\u3067\u3001\u7c21\u5358\u306b\u5024\u3092\u4fdd\u5b58\u3001\u4f7f\u7528\u3059\u308b\u3053\u3068\u304c\u3067\u304d\u307e\u3059\u3002<\/p>\n<p>\u4f8b\u3048\u3070\u4eca\u306e\u5165\u529b\u3068\uff11\u3064\u524d\u306e\u30bf\u30a4\u30e0\u30b9\u30c6\u30c3\u30d7\u306e\u5165\u529b\u3092\u8db3\u3057\u7b97\u3059\u308b\u51e6\u7406\u3092\u4f5c\u3063\u3066\u307f\u307e\u3057\u3087\u3046\u3002\u307e\u305a\u306f\uff11\u3064\u524d\u306e\u5165\u529b\u3092\u4fdd\u5b58\u3059\u308b\u305f\u3081\u306e\u5909\u6570\u3092 properties(Access = private) \u306b\u5b9a\u7fa9\u3057\u307e\u3059\u3002<\/p>\n<p><code><span style=\"color: #0000ff\">properties<span style=\"color: #000000\">(Access = private)<\/span><\/span><br \/>\n  uOld = 0;<br \/>\n<span style=\"color: #0000ff\">end<\/span><br \/>\n<\/code><\/p>\n<p>\u3053\u3053\u3067\u5b9a\u7fa9\u3057\u305f\u5909\u6570\u306e\u5024\u306f\u3001\u30b7\u30df\u30e5\u30ec\u30fc\u30b7\u30e7\u30f3\u304c\u7d42\u308f\u308b\u307e\u3067\u30ea\u30bb\u30c3\u30c8\u3055\u308c\u307e\u305b\u3093\u3002\u305d\u306e\u305f\u3081\u3001\u904e\u53bb\u306e\u5024\u3092\u4fdd\u5b58\u3057\u3066\u304a\u304f\u3053\u3068\u304c\u3067\u304d\u307e\u3059\u3002\u3053\u306e\u5909\u6570\u3092\u4f7f\u3048\u3070\u51fa\u529b\u306e\u8a08\u7b97\u3082\u7c21\u5358\u306b\u4f5c\u308c\u307e\u3059\u306d\u3002<\/p>\n<p><code><span style=\"color: #0000ff\">function<\/span> y = stepImpl(obj,u)<br \/>\n<span style=\"color: #339966\">% Implement algorithm. Calculate y as a function of input u and<\/span><span style=\"color: #339966\"><br \/>\n% discrete states.<br \/>\n<\/span>\u00a0 y = u + obj.uOld; <span style=\"color: #339966\">% \u73fe\u5728\u306e\u5165\u529b\u3068\uff11\u3064\u524d\u306e\u5165\u529b\u3092\u52a0\u7b97<br \/>\n<\/span>\u00a0 obj.uOld = u; <span style=\"color: #339966\">% \u6b21\u306e\u30bf\u30a4\u30e0\u30b9\u30c6\u30c3\u30d7\u306e\u305f\u3081\u306b\u5165\u529b\u3092\u4fdd\u5b58<\/span><br \/>\n<span style=\"color: #0000ff\">end<\/span><\/code><\/p>\n<p>\u524d\u8ff0\u306e properties \u540c\u69d8\u3001\u3053\u3061\u3089\u3082 &#8220;obj.&#8221; \u3092\u3064\u3051\u306a\u304f\u3066\u306f\u3044\u3051\u306a\u3044\u70b9\u306b\u6ce8\u610f\u3067\u3059\u3002<\/p>\n<h2 id=\"second3\"><span style=\"color: #ff6600\">3. \u30b7\u30df\u30e5\u30ec\u30fc\u30b7\u30e7\u30f3\u958b\u59cb\u6642\u306b\uff11\u5ea6\u3060\u3051\u5b9f\u884c\u3057\u305f\u3044\u51e6\u7406\u3092\u7c21\u5358\u306b\u5b9f\u88c5\u3067\u304d\u308b<\/span><\/h2>\n<p><span style=\"color: #000000\">\u30c7\u30fc\u30bf\u306e\u8aad\u307f\u8fbc\u307f\u3084\u521d\u671f\u8a2d\u5b9a\u306a\u3069\u3001\u30b7\u30df\u30e5\u30ec\u30fc\u30b7\u30e7\u30f3\u958b\u59cb\u6642\u306b\uff11\u56de\u3060\u3051\u5b9f\u884c\u3057\u305f\u3044\u51e6\u7406\u304c\u5fc5\u8981\u306a\u5834\u5408\u3001MATLAB Function \u30d6\u30ed\u30c3\u30af\u3067\u306f\u6c38\u7d9a\u5909\u6570\u306a\u3069\u3068\u7d44\u307f\u5408\u308f\u305b\u3066\u521d\u56de\u5b9f\u884c\u304b\u3069\u3046\u304b\u306e\u5224\u5b9a\u3092\u884c\u3046\u5fc5\u8981\u304c\u3042\u308a\u307e\u3059\u3002<\/span><\/p>\n<p>\u3053\u308c\u306b\u5bfe\u3057\u3001MATLAB System \u30d6\u30ed\u30c3\u30af\u306f stepImpl \u95a2\u6570\u3092\u4f7f\u3046\u3053\u3068\u3067\u521d\u56de\u5b9f\u884c\u51e6\u7406\u3092\u7c21\u5358\u306b\u5b9f\u88c5\u3059\u308b\u3053\u3068\u304c\u3067\u304d\u307e\u3059\u3002\u4f8b\u3048\u3070\u3001\u30b7\u30df\u30e5\u30ec\u30fc\u30b7\u30e7\u30f3\u958b\u59cb\u6642\u306b .mat \u30d5\u30a1\u30a4\u30eb\u304b\u3089\u30d1\u30e9\u30e1\u30fc\u30bf\u3092\u8aad\u307f\u8fbc\u307f\u305f\u3044\u5834\u5408\u306f\u4ee5\u4e0b\u306e\u3088\u3046\u306b\u306a\u308a\u307e\u3059\u3002<\/p>\n<p><code><span style=\"color: #0000ff\">properties<span style=\"color: #000000\">(Access = private)<\/span><\/span><br \/>\n  a;<br \/>\n  b; <span style=\"color: #339966\">% \u30d1\u30e9\u30e1\u30fc\u30bf\u4fdd\u5b58\u7528\u306e\u5909\u6570\u3092\u7528\u610f<\/span><br \/>\n<span style=\"color: #0000ff\">end<\/span><\/code><\/p>\n<p><code><span style=\"color: #0000ff\">function<\/span> setupImpl(obj)<br \/>\n<span style=\"color: #339966\">% Perform one-time calculations, such as computing constants<\/span><br \/>\n  data = load(<span style=\"color: #ff00ff\">'myData.mat'<\/span>);<br \/>\n  obj.a = data.a;<br \/>\n  obj.b = data.b; <span style=\"color: #339966\">% \u521d\u56de\u306e\u307f\u30c7\u30fc\u30bf\u30d5\u30a1\u30a4\u30eb\u304b\u3089\u30d1\u30e9\u30e1\u30fc\u30bf\u3092\u8aad\u307f\u8fbc\u3080<\/span><br \/>\n<span style=\"color: #0000ff\">end<\/span><\/code><\/p>\n<p><code><span style=\"color: #0000ff\">function<\/span> y = stepImpl(obj,u)<br \/>\n<span style=\"color: #339966\">% Implement algorithm. Calculate y as a function of input u and<\/span><span style=\"color: #339966\"><br \/>\n% discrete states.<\/span><br \/>\n  y = obj.a * u + obj.b; <span style=\"color: #339966\">% \u521d\u56de\u306b\u8aad\u307f\u8fbc\u3093\u3060 a \u3068 b \u3092\u4f7f\u3063\u3066\u51fa\u529b\u3092\u8a08\u7b97<\/span><br \/>\n<span style=\"color: #0000ff\">end<\/span><\/code><\/p>\n<p>\u524d\u8ff0\u3057\u305f properties(Access = private)\u3068\u7d44\u307f\u5408\u308f\u305b\u3001\u521d\u56de\u6642\u306e\u307f\u30c7\u30fc\u30bf\u30d5\u30a1\u30a4\u30eb\u304b\u3089\u30d1\u30e9\u30e1\u30fc\u30bf\u3092\u8aad\u307f\u8fbc\u307f\u3001\u305d\u308c\u3092\u4f7f\u3063\u3066\u51fa\u529b\u3092\u8a08\u7b97\u3059\u308b\u51e6\u7406\u306e\u4f8b\u3067\u3059\u3002\u5b9f\u884c\u3055\u308c\u308b\u30bf\u30a4\u30df\u30f3\u30b0\u306b\u3088\u3063\u3066\u95a2\u6570\u304c\u5206\u304b\u308c\u3066\u3044\u308b\u5206\u30b3\u30fc\u30c9\u3082\u898b\u3084\u3059\u3044\u3067\u3059\u306d\u3002<\/p>\n<h2 id=\"second4\"><span style=\"color: #ff6600\">4. \u30b3\u30fc\u30c9\u751f\u6210\u306b\u5bfe\u5fdc\u3057\u3066\u3044\u306a\u3044\u95a2\u6570\u3082\u305d\u306e\u307e\u307e\u4f7f\u7528\u53ef\u80fd<\/span><\/h2>\n<p>MATLAB Function \u30d6\u30ed\u30c3\u30af\u306f\u30b3\u30fc\u30c9\u751f\u6210\u5bfe\u5fdc\u3057\u3066\u3044\u306a\u3044\u95a2\u6570\u3092\u4f7f\u3044\u305f\u3044\u5834\u5408\u306f coder.extrinsic \u95a2\u6570\u3067\u30b3\u30fc\u30c9\u751f\u6210\u5bfe\u8c61\u5916\u306b\u3057\u306a\u3051\u308c\u3070\u3044\u3051\u307e\u305b\u3093\u3067\u3057\u305f\u3002\u3053\u308c\u306b\u5bfe\u3057\u3001MATLAB System \u30d6\u30ed\u30c3\u30af\u306f\u30b3\u30fc\u30c9\u751f\u6210\u3092\u884c\u3063\u3066\u30b7\u30df\u30e5\u30ec\u30fc\u30b7\u30e7\u30f3\u3092\u5b9f\u884c\u3059\u308b\u300c\u30b3\u30fc\u30c9\u751f\u6210\u300d\u30e2\u30fc\u30c9\u3068\u3001\u30b3\u30fc\u30c9\u751f\u6210\u3092\u884c\u308f\u305a\u30b7\u30df\u30e5\u30ec\u30fc\u30b7\u30e7\u30f3\u3092\u884c\u3046\u300c\u30a4\u30f3\u30bf\u30fc\u30d7\u30ea\u30bf\u30fc\u578b\u5b9f\u884c\u300d\u30e2\u30fc\u30c9\u3092\u5207\u308a\u66ff\u3048\u308b\u3053\u3068\u304c\u3067\u304d\u307e\u3059\u3002<\/p>\n<p><img decoding=\"async\" loading=\"lazy\" width=\"562\" height=\"236\" class=\"alignnone size-full wp-image-4224\" src=\"https:\/\/blogs.mathworks.com\/japan-community\/files\/2021\/09\/mode.png\" alt=\"\" \/><\/p>\n<p>\u305d\u306e\u305f\u3081\u3001\u30a4\u30f3\u30bf\u30fc\u30d7\u30ea\u30bf\u30fc\u578b\u5b9f\u884c\u3092\u9078\u629e\u3059\u308c\u3070\u3001\u30b3\u30fc\u30c9\u751f\u6210\u306b\u5bfe\u5fdc\u3057\u3066\u3044\u306a\u3044\u95a2\u6570\u3092\u81ea\u7531\u306b\u4f7f\u3046\u3053\u3068\u304c\u3067\u304d\u307e\u3059\u3002\u30b3\u30fc\u30c9\u751f\u6210\u306b\u5bfe\u5fdc\u3057\u3066\u3044\u306a\u3044\u95a2\u6570\u3092\u4f7f\u3044\u305f\u3044\u3060\u3051\u306a\u3089 <a href=\"https:\/\/jp.mathworks.com\/help\/simulink\/slref\/interpretedmatlabfunction.html#responsive_offcanvas\">Interpreted MATLAB Function<\/a> \u30d6\u30ed\u30c3\u30af\u3082\u3042\u308a\u307e\u3059\u304c\u3001\u3053\u3061\u3089\u306f\u72b6\u6cc1\u306b\u5fdc\u3058\u3066\u30b3\u30fc\u30c9\u751f\u6210\u3082\u30a4\u30f3\u30bf\u30fc\u30d7\u30ea\u30bf\u30fc\u5b9f\u884c\u3082\u884c\u3048\u308b\u306e\u304c\u5927\u304d\u306a\u30e1\u30ea\u30c3\u30c8\u3067\u3059\u306d\u3002<\/p>\n<p>\u305f\u3060\u3057\u3001\u30a4\u30f3\u30bf\u30fc\u30d7\u30ea\u30bf\u30fc\u578b\u5b9f\u884c\u30e2\u30fc\u30c9\u306b\u8a2d\u5b9a\u3057\u305f\u5834\u5408\u3001MATLAB System \u5185\u306e\u51e6\u7406\u306f\u3059\u3079\u3066 MATLAB \u5074\u3067\u884c\u308f\u308c\u308b\u3053\u3068\u306b\u306a\u308a\u307e\u3059\u3002\u305d\u306e\u305f\u3081\u3001MATLAB \u3068 Simulink \u306e\u9593\u3067\u3084\u308a\u53d6\u308a\u304c\u767a\u751f\u3057\u3001\u30b7\u30df\u30e5\u30ec\u30fc\u30b7\u30e7\u30f3\u304c\u9045\u304f\u306a\u308b\u53ef\u80fd\u6027\u304c\u3042\u308b\u3053\u3068\u306b\u306f\u6ce8\u610f\u3057\u307e\u3057\u3087\u3046\u3002<\/p>\n<h1 id=\"third\"><span style=\"color: #ff6600\">\u304a\u308f\u308a\u306b<\/span><\/h1>\n<p>\u4eca\u56de\u306f MATLAB System \u30d6\u30ed\u30c3\u30af\u306e\u7c21\u5358\u306a\u4f7f\u3044\u65b9\u3068\u30e1\u30ea\u30c3\u30c8\u306b\u3064\u3044\u3066\u306e\u5185\u5bb9\u3067\u3057\u305f\u3002Simulink \u3092\u4f7f\u3063\u3066\u3044\u308b\u3068\u3001\u3064\u3044\u3064\u3044\u300c\u30d6\u30ed\u30c3\u30af\u306e\u30ab\u30b9\u30bf\u30de\u30a4\u30ba = MATLAB Function \u30d6\u30ed\u30c3\u30af\u300d\u3068\u306a\u3063\u3066\u3057\u307e\u3044\u304c\u3061\u3067\u3059\u304c\u3001MATLAB System \u30d6\u30ed\u30c3\u30af\u3060\u3051\u306b\u9650\u3089\u305a\u3001\u30ab\u30b9\u30bf\u30e0\u30d6\u30ed\u30c3\u30af\u306b\u306f\u305d\u308c\u305e\u308c\u9069\u3057\u305f\u5834\u9762\u304c\u3042\u308a\u307e\u3059\uff08<a href=\"https:\/\/jp.mathworks.com\/help\/simulink\/ug\/comparison-of-custom-block-functionality.html\">\u3053\u3061\u3089<\/a>\u3082\u53c2\u7167\uff09\u306e\u3067\u3001\u81ea\u5206\u304c\u5b9f\u88c5\u3057\u305f\u3044\u51e6\u7406\u306b\u306f\u3069\u306e\u30d6\u30ed\u30c3\u30af\u304c\u6700\u9069\u306a\u306e\u304b\u3092\u4e00\u5ea6\u898b\u76f4\u3057\u3066\u307f\u308b\u3068\u3001\u30e2\u30c7\u30eb\u3084\u30b3\u30fc\u30c9\u3092\u3055\u3089\u306b\u30b7\u30f3\u30d7\u30eb\u306b\u308f\u304b\u308a\u3084\u3059\u304f\u3067\u304d\u308b\u304b\u3082\u3057\u308c\u307e\u305b\u3093\u3088\uff01<\/p>\n","protected":false},"excerpt":{"rendered":"<div class=\"overview-image\"><img decoding=\"async\"  class=\"img-responsive\" src=\"https:\/\/blogs.mathworks.com\/japan-community\/files\/2021\/09\/blockDialog.png\" onError=\"this.style.display ='none';\" \/><\/div>\n<p>\u7686\u3055\u3093\u3053\u3093\u306b\u3061\u306f\u3002\u30c8\u30ec\u30fc\u30cb\u30f3\u30b0\u30a8\u30f3\u30b8\u30cb\u30a2\u306e\u9060\u85e4\u3068\u7533\u3057\u307e\u3059\u3002<br \/>\n\u3053\u306e\u30d6\u30ed\u30b0\u3067\u306f\u3001\u300cSimulink \u3068 MATLAB \u3092\u3064\u306a\u3050\u300d\u3092\u30b3\u30f3\u30bb\u30d7\u30c8\u3068\u3057\u3066\u3001\u4e3b\u306b\u6280\u8853\u7684\u306a\u5185\u5bb9\u306b\u3064\u3044\u3066\u66f8\u3044\u3066\u3044\u307e\u3059\u3002<br \/>\n\u5148\u65e5\u3064\u3044\u306b MATLAB R2021b \u304c\u30ea\u30ea\u30fc\u30b9\u3055\u308c\u307e\u3057\u305f\u306d\uff01Simulink \u3068 MATLAB&#8230; <a class=\"read-more\" href=\"https:\/\/blogs.mathworks.com\/japan-community\/2021\/10\/04\/matlab_system_block\/\">read more >><\/a><\/p>\n","protected":false},"author":169,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":[],"categories":[65,61],"tags":[69],"_links":{"self":[{"href":"https:\/\/blogs.mathworks.com\/japan-community\/wp-json\/wp\/v2\/posts\/4194"}],"collection":[{"href":"https:\/\/blogs.mathworks.com\/japan-community\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blogs.mathworks.com\/japan-community\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blogs.mathworks.com\/japan-community\/wp-json\/wp\/v2\/users\/169"}],"replies":[{"embeddable":true,"href":"https:\/\/blogs.mathworks.com\/japan-community\/wp-json\/wp\/v2\/comments?post=4194"}],"version-history":[{"count":28,"href":"https:\/\/blogs.mathworks.com\/japan-community\/wp-json\/wp\/v2\/posts\/4194\/revisions"}],"predecessor-version":[{"id":4302,"href":"https:\/\/blogs.mathworks.com\/japan-community\/wp-json\/wp\/v2\/posts\/4194\/revisions\/4302"}],"wp:attachment":[{"href":"https:\/\/blogs.mathworks.com\/japan-community\/wp-json\/wp\/v2\/media?parent=4194"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blogs.mathworks.com\/japan-community\/wp-json\/wp\/v2\/categories?post=4194"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blogs.mathworks.com\/japan-community\/wp-json\/wp\/v2\/tags?post=4194"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}