{"id":2801,"date":"2013-10-16T08:45:12","date_gmt":"2013-10-16T13:45:12","guid":{"rendered":"https:\/\/blogs.mathworks.com\/seth\/?p=2801"},"modified":"2013-10-16T14:21:25","modified_gmt":"2013-10-16T19:21:25","slug":"sllinearizer-batch-linearization-of-simulink-models","status":"publish","type":"post","link":"https:\/\/blogs.mathworks.com\/simulink\/2013\/10\/16\/sllinearizer-batch-linearization-of-simulink-models\/","title":{"rendered":"slLinearizer: Batch Linearization of Simulink Models"},"content":{"rendered":"<p>This week I am happy to welcome guest bloggers Charu Fadnavis and <a href=\"https:\/\/www.mathworks.com\/matlabcentral\/fileexchange\/authors\/87056\">Erman Korkut<\/a> to introduce the new <a href=\"https:\/\/www.mathworks.com\/help\/slcontrol\/ug\/sllinearizer.html\"><tt>slLinearizer<\/tt><\/a> interface from <a href=\"https:\/\/www.mathworks.com\/products\/simcontrol\/\">Simulink Control Design<\/a>.<\/p>\r\n\r\n<p><img decoding=\"async\" src=\"https:\/\/blogs.mathworks.com\/images\/seth\/2013Q3\/cfadnavi_and_erman.jpg\" alt=\"Charu Fadnavis and Erman Korkut - The original linearizers\" \/><\/p>\r\n\r\n<p><strong>linearize vs. slLinearizer<\/strong><\/p>\r\n\r\n<p>If you have used Simulink Control Design in the past, the first thing you might wonder is: <em>Why a new interface to linearize Simulink models?<\/em><\/p>\r\n\r\n<p>If you compare the <tt>linearize<\/tt> function with the <tt>slLinearizer<\/tt> interface, you will realize that many linear analysis tasks can be accomplished by both. The main advantage of the <tt>slLinearizer<\/tt> interface is that it makes it easier to obtain multiple transfer functions without recompiling the model, also known as <a href=\"https:\/\/www.mathworks.com\/help\/slcontrol\/batch-linearization.html\">Batch Linearization<\/a>. To get more details on the differences between those two approaches, we recommend going through the documentation page <a href=\"https:\/\/www.mathworks.com\/help\/slcontrol\/ug\/choosing-batch-linearization-tools.html\">Choosing Batch Linearization Tools<\/a>.<\/p>\r\n\r\n<p><strong>The slLinearizer Interface<\/strong><\/p>\r\n\r\n<p>Let's go through a simple example illustrating the basic of the <tt>slLinearizer<\/tt> Interface. For that, we will use a very simple model:<\/p>\r\n\r\n<p><img decoding=\"async\" src=\"https:\/\/blogs.mathworks.com\/images\/seth\/2013Q3\/linModel.png\" alt=\"simple example model to be linearized\" \/><\/p>\r\n\r\n<p>The first step is to create a <tt>slLinearizer<\/tt> object for your model.<\/p>\r\n\r\n<p><img decoding=\"async\" src=\"https:\/\/blogs.mathworks.com\/images\/seth\/2013Q3\/lsLinearizerObject.png\" alt=\"slLinearizerInterface\" \/><\/p>\r\n\r\n<p>Once the object is created, you want to add analysis points. One important difference when compared to the <tt>linearize<\/tt> workflow is that with the <tt>slLinearizer<\/tt> interface, the points that you specify are much more flexible. When adding points, you do not need to specify if they are input, output, open or closed loop, etc.<\/p>\r\n\r\n<p>To add points, you can use block name and port number, or signal names. For this example, let's add multiple points.<\/p>\r\n\r\n<p><img decoding=\"async\" src=\"https:\/\/blogs.mathworks.com\/images\/seth\/2013Q3\/addPoints.png\" alt=\"adding points\" \/><\/p>\r\n\r\n<p>We can now use any of the four <tt>get*<\/tt> methods to obtain transfer functions for the different points and loop openings: <a href=\"https:\/\/www.mathworks.com\/help\/slcontrol\/ug\/getiotransfer.html\"><tt>getIOTransfer<\/tt><\/a>, <a href=\"https:\/\/www.mathworks.com\/help\/slcontrol\/ug\/getlooptransfer.html\"><tt>getLoopTransfer<\/tt><\/a>, <a href=\"https:\/\/www.mathworks.com\/help\/slcontrol\/ug\/getsensitivity.html\"><tt>getSensitivity<\/tt><\/a>, <a href=\"https:\/\/www.mathworks.com\/help\/slcontrol\/ug\/getcompsensitivity.html\"><tt>getCompSensitivity<\/tt><\/a>.<\/p>\r\n\r\n<p>For example, if I want to get the transfer function between the reference <tt>r<\/tt> and the output <tt>y:<\/tt><\/p>\r\n\r\n<p><img decoding=\"async\" src=\"https:\/\/blogs.mathworks.com\/images\/seth\/2013Q3\/getiotransfer_r2y.png\" alt=\"I\/O Transfer Function\" \/><\/p>\r\n\r\n<p>I use <tt>getIOTransfer<\/tt>:<\/p>\r\n\r\n<p><img decoding=\"async\" src=\"https:\/\/blogs.mathworks.com\/images\/seth\/2013Q3\/iotransfer.png\" alt=\"Result of getIOTransfer\" \/><\/p>\r\n\r\n<p>If I want the sensitivity at the control signal <tt>u<\/tt>:<\/p>\r\n\r\n<p><img decoding=\"async\" src=\"https:\/\/blogs.mathworks.com\/images\/seth\/2013Q3\/getsensitivity1.png\" alt=\"Sensitivity\" \/><\/p>\r\n\r\n<p>I use <tt>getSensitivity<\/tt><\/p>\r\n\r\n<p><img decoding=\"async\" src=\"https:\/\/blogs.mathworks.com\/images\/seth\/2013Q3\/sensitivity.png\" alt=\"Sensitivity\" \/><\/p>\r\n\r\n<p>The important thing to note, is that the model will be compiled <strong>only the first time one of the <tt>get*<\/tt> method is called<\/strong>.<\/p>\r\n\r\n<p><strong>Batch linearization<\/strong><\/p>\r\n\r\n<p>In addition to linearizing for multiple analysis points and loop opening without recompiling the model, the <tt>slLinearizer<\/tt> interface makes it easy to obtain multiple linearizations for a set of operating points or parameter values.<\/p>\r\n\r\n<p>For the example above, let's say we want to obtain a series of transfer functions for different values of controller gain <tt>k<\/tt>, all you have to do is:<\/p>\r\n\r\n<p><img decoding=\"async\" src=\"https:\/\/blogs.mathworks.com\/images\/seth\/2013Q3\/batchLinParams.png\" alt=\"Batch Linearization for a vector of parameters\" \/><\/p>\r\n\r\n<p>and you obtain an array of transfer functions:<\/p>\r\n\r\n<p><img decoding=\"async\" src=\"https:\/\/blogs.mathworks.com\/images\/seth\/2013Q3\/multipleStepResponse.png\" alt=\"Step Response of transfer functions\" \/><\/p>\r\n\r\n<p>If what you need to study is linearization at multiple operating points, it can also be done with the <tt>slLinearizer<\/tt> interface. For a detailed example of this workflow, see <a href=\"https:\/\/www.mathworks.com\/help\/slcontrol\/ug\/batch-linearization-for-multiple-io-sets-using-sllinearizer.html\">Vary Operating Points and Obtain Multiple Transfer Functions Using slLinearizer<\/a>.<\/p>\r\n\r\n<p><strong>Now It's Your Turn<\/strong><\/p>\r\n\r\n<p>Check out the documentation for slLinearizer and try linearizing your model with it. We'd love to <a href=\"https:\/\/blogs.mathworks.com\/seth\/?p=2801&#comment\">hear your thoughts<\/a>!<\/p>\r\n\r\n\r\n\r\n<\/p>\r\n","protected":false},"excerpt":{"rendered":"<div class=\"overview-image\"><img decoding=\"async\"  class=\"img-responsive\" src=\"https:\/\/blogs.mathworks.com\/images\/seth\/2013Q3\/multipleStepResponse.png\" onError=\"this.style.display ='none';\" \/><\/div><p>This week I am happy to welcome guest bloggers Charu Fadnavis and Erman Korkut to introduce the new slLinearizer interface from Simulink Control Design.\r\n\r\n\r\n\r\nlinearize vs. slLinearizer\r\n\r\nIf you... <a class=\"read-more\" href=\"https:\/\/blogs.mathworks.com\/simulink\/2013\/10\/16\/sllinearizer-batch-linearization-of-simulink-models\/\">read more >><\/a><\/p>","protected":false},"author":41,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":[],"categories":[115,65,143,16],"tags":[345,116,344],"_links":{"self":[{"href":"https:\/\/blogs.mathworks.com\/simulink\/wp-json\/wp\/v2\/posts\/2801"}],"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\/41"}],"replies":[{"embeddable":true,"href":"https:\/\/blogs.mathworks.com\/simulink\/wp-json\/wp\/v2\/comments?post=2801"}],"version-history":[{"count":32,"href":"https:\/\/blogs.mathworks.com\/simulink\/wp-json\/wp\/v2\/posts\/2801\/revisions"}],"predecessor-version":[{"id":2857,"href":"https:\/\/blogs.mathworks.com\/simulink\/wp-json\/wp\/v2\/posts\/2801\/revisions\/2857"}],"wp:attachment":[{"href":"https:\/\/blogs.mathworks.com\/simulink\/wp-json\/wp\/v2\/media?parent=2801"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blogs.mathworks.com\/simulink\/wp-json\/wp\/v2\/categories?post=2801"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blogs.mathworks.com\/simulink\/wp-json\/wp\/v2\/tags?post=2801"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}