{"id":5524,"date":"2014-09-12T16:30:47","date_gmt":"2014-09-12T20:30:47","guid":{"rendered":"https:\/\/blogs.mathworks.com\/pick\/?p=5524"},"modified":"2014-09-12T16:30:47","modified_gmt":"2014-09-12T20:30:47","slug":"simscape-language-nonlinear-rotational-spring","status":"publish","type":"post","link":"https:\/\/blogs.mathworks.com\/pick\/2014\/09\/12\/simscape-language-nonlinear-rotational-spring\/","title":{"rendered":"Simscape Language: Nonlinear Rotational Spring"},"content":{"rendered":"<div xmlns:mwsh=\"https:\/\/www.mathworks.com\/namespace\/mcode\/v1\/syntaxhighlight.dtd\" class=\"content\">\r\n   <introduction>\r\n      <p><a href=\"https:\/\/www.mathworks.com\/matlabcentral\/answers\/contributors\/3208495\">Sean<\/a>'s pick this week is <a href=\"https:\/\/www.mathworks.com\/matlabcentral\/fileexchange\/25238-simscape-language--nonlinear-spring\">Simscape Language: Nonlinear Rotational Spring<\/a> by <a href=\"https:\/\/www.mathworks.com\/matlabcentral\/fileexchange\/authors\/29641\">Steve Miller<\/a>.\r\n      <\/p>\r\n   <\/introduction>\r\n\r\n   <p>I spend a fair amount of time exploring the MathWorks product suite trying to learn new things.  Exploring the File Exchange,\r\n      I came upon this example of a nonlinear spring.  Having not had much opportunity to use our <a href=\"https:\/\/www.mathworks.com\/solutions\/physical-modeling.html\">Physical Modeling Tools<\/a>  this example caught my eye because it uses something us civil\/structural engineers are familiar with: springs!\r\n   <\/p>\r\n   <p>The example includes a README file to get started, a PDF file, and a link to a video.  Not going to lie, I didn't watch the\r\n      video.  But I didn't have to!  The model documents how things work and the README gave me all of the instructions necessary\r\n      to get this off the ground.\r\n   <\/p>\r\n   <p>Here is the model and the scope showing a linear spring compared to the nonlinear spring:<\/p>\r\n   <p><img decoding=\"async\" vspace=\"5\" hspace=\"5\" src=\"https:\/\/blogs.mathworks.com\/images\/pick\/Sean\/mainNonLinearSpring\/springImage1.PNG\"> <\/p>\r\n   <p>This is the design of the nonlinear spring in the <a href=\"\">Simscape Language<\/a>.\r\n   <\/p>\r\n   <p><img decoding=\"async\" vspace=\"5\" hspace=\"5\" src=\"https:\/\/blogs.mathworks.com\/images\/pick\/Sean\/mainNonLinearSpring\/componentImage1.PNG\"> <\/p>\r\n   <p>Out of curiosity, I wanted to see what would happen for a much stiffer spring (that's what structural engineers use!), so\r\n      I changed the value of <i>spring_rate<\/i> to 50 and reran the model:\r\n   <\/p>\r\n   <p><img decoding=\"async\" vspace=\"5\" hspace=\"5\" src=\"https:\/\/blogs.mathworks.com\/images\/pick\/Sean\/mainNonLinearSpring\/newK.PNG\"> <\/p>\r\n   <p>And that's the best part about simulation: I didn't have to go buy or test a bigger spring to see what would happen.<\/p>\r\n   <h3>Comments<a name=\"2\"><\/a><\/h3>\r\n   <p>Give it a try and let us know what you think <a href=\"https:\/\/blogs.mathworks.com\/pick\/?p=5524#respond\">here<\/a> or leave a <a href=\"https:\/\/www.mathworks.com\/matlabcentral\/fileexchange\/25238-simscape-language--nonlinear-spring#comments\">comment<\/a> for Steve.\r\n   <\/p><script language=\"JavaScript\">\r\n<!--\r\n\r\n    function grabCode_ad07a5904d554ca2a5d0547535554c44() {\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='ad07a5904d554ca2a5d0547535554c44 ' + '##### ' + 'SOURCE BEGIN' + ' #####';\r\n        t2='##### ' + 'SOURCE END' + ' #####' + ' ad07a5904d554ca2a5d0547535554c44';\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 = 'Sean de Wolski';\r\n        copyright = 'Copyright 2014 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_ad07a5904d554ca2a5d0547535554c44()\"><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; R2014a<br><\/p>\r\n<\/div>\r\n<!--\r\nad07a5904d554ca2a5d0547535554c44 ##### SOURCE BEGIN #####\r\n%% Simscape Language: Nonlinear Rotational Spring\r\n%\r\n% <https:\/\/www.mathworks.com\/matlabcentral\/answers\/contributors\/3208495 Sean>'s pick this week is\r\n% <https:\/\/www.mathworks.com\/matlabcentral\/fileexchange\/25238-simscape-language--nonlinear-spring Simscape Language: Nonlinear Rotational Spring> by\r\n% <https:\/\/www.mathworks.com\/matlabcentral\/fileexchange\/authors\/29641 Steve Miller>.\r\n% \r\n\r\n%% \r\n% I spend a fair amount of time exploring the MathWorks product suite\r\n% trying to learn new things.  Exploring the File Exchange, I came upon\r\n% this example of a nonlinear spring.  Having not had much opportunity to\r\n% use our <https:\/\/www.mathworks.com\/solutions\/physical-modeling.html Physical Modeling\r\n% Tools>  this example caught my eye because it uses something us\r\n% civil\/structural engineers are familiar with: springs!\r\n%\r\n% The example includes a README file to get started, a PDF file, and a link\r\n% to a video.  Not going to lie, I didn't watch the video.  But I didn't\r\n% have to!  The model documents how things work and the README gave me all\r\n% of the instructions necessary to get this off the ground.\r\n%\r\n% Here is the model and the scope showing a linear spring compared to the\r\n% nonlinear spring:\r\n%\r\n% <<springImage1.PNG>>\r\n%\r\n% This is the design of nonlinear spring in the\r\n% <\r\n% Simscape Language>.\r\n%\r\n% <<componentImage1.PNG>>\r\n%\r\n% Out of curiosity, I wanted to see what would happen for a much stiffer\r\n% spring (that's what structural engineers use!), so I changed\r\n% the value of _spring_rate_ to 50 and reran the model:\r\n%\r\n% <<newK.PNG>>\r\n%\r\n% And that's the best part about simulation: I didn't have to go buy or\r\n% test a bigger spring to see what would happen.\r\n\r\n%% Comments\r\n% \r\n% Give it a try and let us know what you think\r\n% <https:\/\/blogs.mathworks.com\/pick\/?p=5524#respond here> or leave a\r\n% <https:\/\/www.mathworks.com\/matlabcentral\/fileexchange\/25238-simscape-language--nonlinear-spring#comments\r\n% comment> for Steve.\r\n%\r\n \r\n\r\n##### SOURCE END ##### ad07a5904d554ca2a5d0547535554c44\r\n-->","protected":false},"excerpt":{"rendered":"<div class=\"overview-image\"><img decoding=\"async\"  class=\"img-responsive\" src=\"https:\/\/blogs.mathworks.com\/images\/pick\/Sean\/mainNonLinearSpring\/springImage1.PNG\" onError=\"this.style.display ='none';\" \/><\/div><p>\r\n   \r\n      Sean's pick this week is Simscape Language: Nonlinear Rotational Spring by Steve Miller.\r\n      \r\n   \r\n\r\n   I spend a fair amount of time exploring the MathWorks product suite trying to... <a class=\"read-more\" href=\"https:\/\/blogs.mathworks.com\/pick\/2014\/09\/12\/simscape-language-nonlinear-rotational-spring\/\">read more >><\/a><\/p>","protected":false},"author":87,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":[],"categories":[16],"tags":[],"_links":{"self":[{"href":"https:\/\/blogs.mathworks.com\/pick\/wp-json\/wp\/v2\/posts\/5524"}],"collection":[{"href":"https:\/\/blogs.mathworks.com\/pick\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blogs.mathworks.com\/pick\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blogs.mathworks.com\/pick\/wp-json\/wp\/v2\/users\/87"}],"replies":[{"embeddable":true,"href":"https:\/\/blogs.mathworks.com\/pick\/wp-json\/wp\/v2\/comments?post=5524"}],"version-history":[{"count":6,"href":"https:\/\/blogs.mathworks.com\/pick\/wp-json\/wp\/v2\/posts\/5524\/revisions"}],"predecessor-version":[{"id":5530,"href":"https:\/\/blogs.mathworks.com\/pick\/wp-json\/wp\/v2\/posts\/5524\/revisions\/5530"}],"wp:attachment":[{"href":"https:\/\/blogs.mathworks.com\/pick\/wp-json\/wp\/v2\/media?parent=5524"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blogs.mathworks.com\/pick\/wp-json\/wp\/v2\/categories?post=5524"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blogs.mathworks.com\/pick\/wp-json\/wp\/v2\/tags?post=5524"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}