{"id":4,"date":"2008-02-26T17:00:17","date_gmt":"2008-02-26T21:00:17","guid":{"rendered":"https:\/\/blogs.mathworks.com\/seth\/2008\/02\/26\/welcome\/"},"modified":"2011-07-11T18:19:00","modified_gmt":"2011-07-11T18:19:00","slug":"welcome","status":"publish","type":"post","link":"https:\/\/blogs.mathworks.com\/simulink\/2008\/02\/26\/welcome\/","title":{"rendered":"Welcome!"},"content":{"rendered":"<div xmlns:mwsh=\"https:\/\/www.mathworks.com\/namespace\/mcode\/v1\/syntaxhighlight.dtd\" class=\"content\">\r\n   <introduction>\r\n      <p>Welcome to the MATLAB Central Simulink blog! The purpose of this blog is twofold: First, I want to share Simulink tips and\r\n         tricks that I've learned over the years. At the same time, I hope to learn from you about your experiences with Simulink.\r\n         Where is it good? How can we improve it?\r\n      <\/p>\r\n      <p>I've been using Simulink for 9 years, first as a member of our technical support team, and then as a trainer. I still remember\r\n         when I first learned about the power of Simulink as a newly hired support engineer back in 1998. During a training class I\r\n         saw differential equations drawn on a whiteboard and then simulated with a few clicks of the mouse. I got excited by how clearly\r\n         it all worked. Simulink provided me with a framework for thinking about systems and the relationships between their basic\r\n         components.\r\n      <\/p>\r\n      <p>Of course, Simulink is much more than a simple tool for solving differential equations. It has a richness and depth that will\r\n         give me plenty of material to draw on. What kind of topics can you expect to read about here? We'll talk about applications\r\n         of Simulink in controls, signal processing and communications system design. With your help, we'll talk about how Simulink\r\n         is used in areas I don't even know about yet. We'll talk about Model-Based Design in general, and we'll get a peek at some\r\n         of the internal machinery of Simulink. I look forward to posts about all of these:\r\n      <\/p>\r\n      <div>\r\n         <ul>\r\n            <li>solvers<\/li>\r\n            <li>sample times<\/li>\r\n            <li>modeling<\/li>\r\n            <li>hacks<\/li>\r\n            <li>blocks<\/li>\r\n            <li>model reference<\/li>\r\n            <li>libraries<\/li>\r\n            <li>masking<\/li>\r\n            <li>custom code<\/li>\r\n         <\/ul>\r\n      <\/div>\r\n   <\/introduction>\r\n   <p><b>An example: batch simulation<\/b><\/p>\r\n   <p>Let me start off with a specific example about running simulations. Simulink models are built using block diagrams, and once\r\n      they've been created most everyone runs them by clicking the run button on the toolbar.\r\n   <\/p>\r\n   <p><img decoding=\"async\" vspace=\"5\" hspace=\"5\" src=\"https:\/\/blogs.mathworks.com\/images\/seth\/2008Q1\/vdp_PlayButton.png\"> <\/p>\r\n   <p>If you have to run a sweep of parameters you might change the parameter and then click run, change it again and click run.\r\n       But if you have to run hundreds or thousands of simulations while modifying a parameter you will want to write a script for\r\n      batch simulation.  You can run simulations directly from MATLAB with the <tt>sim<\/tt> command like so.\r\n   <\/p><pre>&gt;&gt; [t,x,y] = sim(sys);<\/pre><p>This returns the root level outputs (y) and the internal states of the model (x) at each recorded time step (t).  A batch\r\n      script might look like this:\r\n   <\/p><pre style=\"background: #F9F7F3; padding: 10px; border: 1px solid rgb(200,200,200)\">open_system(<span style=\"color: #A020F0\">'vdp_mu'<\/span>)\r\nmuSweep = .5:.1:1.5;\r\n<span style=\"color: #0000FF\">for<\/span> i = 1:length(muSweep)\r\n    mu = muSweep(i);\r\n    [t,x,y] = sim(<span style=\"color: #A020F0\">'vdp_mu'<\/span>);\r\n    plot(t,y); hold <span style=\"color: #A020F0\">on<\/span>;\r\n<span style=\"color: #0000FF\">end<\/span>\r\ntitle(<span style=\"color: #A020F0\">'VDP States for mu=.5 to 1.5'<\/span>)\r\nxlabel(<span style=\"color: #A020F0\">'Time'<\/span>); legend(<span style=\"color: #A020F0\">'x1'<\/span>,<span style=\"color: #A020F0\">'x2'<\/span>)<\/pre><img decoding=\"async\" vspace=\"5\" hspace=\"5\" src=\"https:\/\/blogs.mathworks.com\/images\/seth\/2008Q1\/welcome_01.png\"> <p>If you are already familiar with the <tt>sim<\/tt> command, then you probably know that some times you are only interested in the outputs (y) of the model, and not the states\r\n      (x).  For large models, or long simulations, those state variable outputs could be a waste of valuable memory.  Using <tt>simset<\/tt> you can provide additional options to the <tt>sim<\/tt> command to specify that you only want time (t) and outputs (y).  The state variable returned from <tt>sim<\/tt> will be empty.\r\n   <\/p><pre style=\"background: #F9F7F3; padding: 10px; border: 1px solid rgb(200,200,200)\">[t,x,y] = sim(<span style=\"color: #A020F0\">'vdp_mu'<\/span>,[],simset(<span style=\"color: #A020F0\">'OutputVariables'<\/span>,<span style=\"color: #A020F0\">'ty'<\/span>));\r\nwhos <span style=\"color: #A020F0\">t<\/span> <span style=\"color: #A020F0\">x<\/span> <span style=\"color: #A020F0\">y<\/span><\/pre><pre style=\"font-style:oblique\">  Name        Size            Bytes  Class     Attributes\r\n\r\n  t         206x1              1648  double              \r\n  x           0x0                 0  double              \r\n  y         206x2              3296  double              \r\n\r\n<\/pre><p>You can learn more about <a href=\"https:\/\/www.mathworks.com\/help\/simulink\/slref\/sim.html\"><tt>sim<\/tt> and <tt>simset<\/tt> in the Simulink documentation<\/a>.\r\n   <\/p>\r\n   <p><b>What do you think?<\/b><\/p>\r\n   <p>That's your first Simulink tip. Now it's your turn. What do you like about Simulink? What would you like to talk about in\r\n      future posts? Please leave a comment below. I have learned from <a href=\"https:\/\/blogs.mathworks.com\/pick\">Doug<\/a> that t-shirts get comments on your blog, so I'll be randomly selecting five commenters on this post to receive a MathWorks\r\n      t-shirt!\r\n   <\/p><script language=\"JavaScript\">\r\n<!--\r\n\r\n    function grabCode_8617be9626294d678a4bb72e117399c6() {\r\n        \/\/ Remember the title so we can use it in the new page\r\n        title = document.title;\r\n\r\n        \/\/ Break up these strings so that their presence\r\n        \/\/ in the Javascript doesn't mess up the search for\r\n        \/\/ the MATLAB code.\r\n        t1='8617be9626294d678a4bb72e117399c6 ' + '##### ' + 'SOURCE BEGIN' + ' #####';\r\n        t2='##### ' + 'SOURCE END' + ' #####' + ' 8617be9626294d678a4bb72e117399c6';\r\n    \r\n        b=document.getElementsByTagName('body')[0];\r\n        i1=b.innerHTML.indexOf(t1)+t1.length;\r\n        i2=b.innerHTML.indexOf(t2);\r\n \r\n        code_string = b.innerHTML.substring(i1, i2);\r\n        code_string = code_string.replace(\/REPLACE_WITH_DASH_DASH\/g,'--');\r\n\r\n        \/\/ Use \/x3C\/g instead of the less-than character to avoid errors \r\n        \/\/ in the XML parser.\r\n        \/\/ Use '\\x26#60;' instead of '<' so that the XML parser\r\n        \/\/ doesn't go ahead and substitute the less-than character. \r\n        code_string = code_string.replace(\/\\x3C\/g, '\\x26#60;');\r\n\r\n        author = 'Seth Popinchalk';\r\n        copyright = 'Copyright 2008 The MathWorks, Inc.';\r\n\r\n        w = window.open();\r\n        d = w.document;\r\n        d.write('<pre>\\n');\r\n        d.write(code_string);\r\n\r\n        \/\/ Add author and copyright lines at the bottom if specified.\r\n        if ((author.length > 0) || (copyright.length > 0)) {\r\n            d.writeln('');\r\n            d.writeln('%%');\r\n            if (author.length > 0) {\r\n                d.writeln('% _' + author + '_');\r\n            }\r\n            if (copyright.length > 0) {\r\n                d.writeln('% _' + copyright + '_');\r\n            }\r\n        }\r\n\r\n        d.write('<\/pre>\\n');\r\n      \r\n      d.title = title + ' (MATLAB code)';\r\n      d.close();\r\n      }   \r\n      \r\n-->\r\n<\/script><p style=\"text-align: right; font-size: xx-small; font-weight:lighter;   font-style: italic; color: gray\"><br><a href=\"javascript:grabCode_8617be9626294d678a4bb72e117399c6()\"><span style=\"font-size: x-small;        font-style: italic;\">Get \r\n            the MATLAB code \r\n            <noscript>(requires JavaScript)<\/noscript><\/span><\/a><br><br>\r\n      Published with MATLAB&reg; 7.5<br><\/p>\r\n<\/div>\r\n<!--\r\n8617be9626294d678a4bb72e117399c6 ##### SOURCE BEGIN #####\r\n%%\r\n% Welcome to the MATLAB Central Simulink blog! The purpose of this blog\r\n% is twofold: First, I want to share Simulink tips and tricks that I've\r\n% learned over the years. At the same time, I hope to learn from you about\r\n% your experiences with Simulink. Where is it good? How can we improve it? \r\n% \r\n% I've been using Simulink for 9 years, first as a member of our technical\r\n% support team, and then as a trainer. I still remember when I first\r\n% learned about the power of Simulink as a newly hired support engineer\r\n% back in 1998. During a training class I saw differential equations drawn\r\n% on a whiteboard and then simulated with a few clicks of the mouse. I got\r\n% excited by how clearly it all worked. Simulink provided me with a\r\n% framework for thinking about systems and the relationships between their\r\n% basic components.\r\n% \r\n% Of course, Simulink is much more than a simple tool for solving\r\n% differential equations. It has a richness and depth that will give me\r\n% plenty of material to draw on. What kind of topics can you expect to read\r\n% about here? We'll talk about applications of Simulink in controls, signal\r\n% processing and communications system design. With your help, we'll talk\r\n% about how Simulink is used in areas I don't even know about yet. We'll\r\n% talk about Model-Based Design in general, and we'll get a peek at some of\r\n% the internal machinery of Simulink. I look forward to posts about all of\r\n% these:\r\n%\r\n% * solvers\r\n% * sample times\r\n% * modeling\r\n% * hacks\r\n% * blocks\r\n% * model reference\r\n% * libraries\r\n% * masking\r\n% * custom code\r\n%\r\n%%\r\n% *An example: batch simulation*\r\n%\r\n% Let me start off with a specific example about running simulations.\r\n% Simulink models are built using block diagrams, and once they've been\r\n% created most everyone runs them by clicking the run button on the\r\n% toolbar.\r\n%%\r\n% <<vdp_PlayButton.png>>\r\n%%\r\n% If you have to run a sweep of parameters you might change the parameter\r\n% and then click run, change it again and click run.  But if you have to\r\n% run hundreds or thousands of simulations while modifying a parameter you\r\n% will want to write a script for batch simulation.  You can run\r\n% simulations directly from MATLAB with the |sim| command like so.\r\n%\r\n%  >> [t,x,y] = sim(sys);\r\n%\r\n% This returns the root level outputs (y) and the internal states of the\r\n% model (x) at each recorded time step (t).  A batch script might look like\r\n% this:\r\n%\r\nopen_system('vdp_mu')\r\nmuSweep = .5:.1:1.5;\r\nfor i = 1:length(muSweep)\r\n    mu = muSweep(i);\r\n    [t,x,y] = sim('vdp_mu');\r\n    plot(t,y); hold on;\r\nend\r\ntitle('VDP States for mu=.5 to 1.5')\r\nxlabel('Time'); legend('x1','x2')\r\n\r\n%%\r\n% If you are already familiar with the |sim| command, then you probably know\r\n% that some times you are only interested in the outputs (y) of the model,\r\n% and not the states (x).  For large models, or long simulations, those\r\n% state variable outputs could be a waste of valuable memory.  Using |simset|\r\n% you can provide additional options to the |sim| command to specify that you\r\n% only want time (t) and outputs (y).  The state variable returned from |sim| \r\n% will be empty.\r\n%%\r\n[t,x,y] = sim('vdp_mu',[],simset('OutputVariables','ty'));\r\nwhos t x y\r\n\r\n%% \r\n% You can learn more about <https:\/\/www.mathworks.com\/help\/simulink\/slref\/sim.html |sim| and |simset| in the Simulink documentation>.\r\n\r\n%%\r\n% *What do you think?*\r\n%\r\n% That's your first Simulink tip. Now it's your turn. What do you like\r\n% about Simulink? What would you like to talk about in future posts? Please\r\n% leave a comment below. I have learned from <https:\/\/blogs.mathworks.com\/pick Doug> \r\n% that t-shirts get comments on your blog, so I'll be randomly selecting\r\n% five commenters on this post to receive a MathWorks t-shirt!\r\n##### SOURCE END ##### 8617be9626294d678a4bb72e117399c6\r\n-->","protected":false},"excerpt":{"rendered":"<p>\r\n   \r\n      Welcome to the MATLAB Central Simulink blog! The purpose of this blog is twofold: First, I want to share Simulink tips and\r\n         tricks that I've learned over the years. At the same... <a class=\"read-more\" href=\"https:\/\/blogs.mathworks.com\/simulink\/2008\/02\/26\/welcome\/\">read more >><\/a><\/p>","protected":false},"author":40,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":[],"categories":[10],"tags":[],"_links":{"self":[{"href":"https:\/\/blogs.mathworks.com\/simulink\/wp-json\/wp\/v2\/posts\/4"}],"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=4"}],"version-history":[{"count":0,"href":"https:\/\/blogs.mathworks.com\/simulink\/wp-json\/wp\/v2\/posts\/4\/revisions"}],"wp:attachment":[{"href":"https:\/\/blogs.mathworks.com\/simulink\/wp-json\/wp\/v2\/media?parent=4"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blogs.mathworks.com\/simulink\/wp-json\/wp\/v2\/categories?post=4"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blogs.mathworks.com\/simulink\/wp-json\/wp\/v2\/tags?post=4"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}