{"id":59,"date":"2009-06-26T20:09:19","date_gmt":"2009-06-26T20:09:19","guid":{"rendered":"https:\/\/blogs.mathworks.com\/seth\/2009\/06\/26\/my-mental-model-of-a-model\/"},"modified":"2009-06-26T20:09:19","modified_gmt":"2009-06-26T20:09:19","slug":"my-mental-model-of-a-model","status":"publish","type":"post","link":"https:\/\/blogs.mathworks.com\/simulink\/2009\/06\/26\/my-mental-model-of-a-model\/","title":{"rendered":"My Mental Model of a Model"},"content":{"rendered":"<p>When you are new to something, it always helps to get a\r\nmental picture of how that something works.\u00a0 Since I learned Simulink over 10\r\nyears ago, I have developed my own mental model of Simulink models.\u00a0 Today I\r\nwant to present a mental model for the three basic components in Simulink block\r\ndiagrams, ports, blocks and signals.<\/p>\r\n\r\n<p><strong>Something Familiar<\/strong><\/p>\r\n\r\n<p>A good mental model is something to which you are already\r\nfamiliar.\u00a0 I like to compare Simulink diagrams to programs written in a\r\nprocedural language like MATLAB or C.\u00a0 My favorite is MATLAB, so that is\r\nusually how I think.<\/p>\r\n\r\n<p><strong>Ports<\/strong><\/p>\r\n\r\n<p>Ports are the input and output arguments for the function.<\/p>\r\n\r\n<p><strong>Blocks<\/strong><\/p>\r\n\r\n<p>When I think about blocks, I think of them as algorithmic\r\ncomponents of the programs.\u00a0 A block like the Gain or Product is a function\r\nthat operates on inputs and produces an output.<\/p>\r\n\r\n<p><strong>Signals<\/strong><\/p>\r\n\r\n<p>Signal lines pass the value output from one block to the\r\nnext block.\u00a0 I think of signal lines as the variables in a program.<\/p>\r\n\r\n<p><img decoding=\"async\" src=\"https:\/\/blogs.mathworks.com\/images\/seth\/2009Q2\/foo_mdl_m_highlighted.png\" alt=\"A Simulink block diagram and corresponding M-code to illustrate my mental model.\"><\/p>\r\n\r\n<p><strong>Generating Code<\/strong><\/p>\r\n\r\n<p>With my intuition in hand, I read the generated code so I\r\ncan compare and refine my mental model.\u00a0 The result is here:<\/p>\r\n\r\n<p><img decoding=\"async\" src=\"https:\/\/blogs.mathworks.com\/images\/seth\/2009Q2\/foo_mdl_ERTCode.png\" alt=\"The generated code from the model.  Pretty close to the mental model.\"><\/p>\r\n\r\n<p>In this case, I made a couple tweaks to the code generation\r\nsettings for readability and interface.\u00a0 <\/p>\r\n\r\n<p><strong>What do you think?<\/strong><\/p>\r\n\r\n<p>How does your mental model of a block diagram compare to\r\nmine?\u00a0 Leave a <a href=\"https:\/\/blogs.mathworks.com\/seth\/?p=59&amp;#comment\">comment\r\nhere<\/a> and share it with me.<\/p>","protected":false},"excerpt":{"rendered":"<p>When you are new to something, it always helps to get a\r\nmental picture of how that something works.\u00a0 Since I learned Simulink over 10\r\nyears ago, I have developed my own mental model of Simulink... <a class=\"read-more\" href=\"https:\/\/blogs.mathworks.com\/simulink\/2009\/06\/26\/my-mental-model-of-a-model\/\">read more >><\/a><\/p>","protected":false},"author":40,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":[],"categories":[21,67,30,55],"tags":[97,96,441],"_links":{"self":[{"href":"https:\/\/blogs.mathworks.com\/simulink\/wp-json\/wp\/v2\/posts\/59"}],"collection":[{"href":"https:\/\/blogs.mathworks.com\/simulink\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blogs.mathworks.com\/simulink\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blogs.mathworks.com\/simulink\/wp-json\/wp\/v2\/users\/40"}],"replies":[{"embeddable":true,"href":"https:\/\/blogs.mathworks.com\/simulink\/wp-json\/wp\/v2\/comments?post=59"}],"version-history":[{"count":0,"href":"https:\/\/blogs.mathworks.com\/simulink\/wp-json\/wp\/v2\/posts\/59\/revisions"}],"wp:attachment":[{"href":"https:\/\/blogs.mathworks.com\/simulink\/wp-json\/wp\/v2\/media?parent=59"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blogs.mathworks.com\/simulink\/wp-json\/wp\/v2\/categories?post=59"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blogs.mathworks.com\/simulink\/wp-json\/wp\/v2\/tags?post=59"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}