{"id":168,"date":"2011-11-20T10:16:29","date_gmt":"2011-11-20T10:16:29","guid":{"rendered":"https:\/\/blogs.mathworks.com\/seth\/2011\/11\/20\/sample-time-offset\/"},"modified":"2018-06-11T11:32:07","modified_gmt":"2018-06-11T16:32:07","slug":"sample-time-offset","status":"publish","type":"post","link":"https:\/\/blogs.mathworks.com\/simulink\/2011\/11\/20\/sample-time-offset\/","title":{"rendered":"Sample Time Offset"},"content":{"rendered":"<p>I noticed that many users are not aware that it is possible to specify sample time offsets in Simulink.<\/p>\r\n\r\n<p><strong>Scalar Sample Time<\/strong><\/p>\r\n\r\n<p>In this simple model, I have specified the sample time of the Constant and the Discrete Integrator to 0.1s and the sample time of the Rate Transition block to 1s. This means that the Gain block will execute at time 0s, 1s, 2s, 3s, ...<\/p>\r\n\r\n<p><img decoding=\"async\" src=\"https:\/\/blogs.mathworks.com\/images\/seth\/2011Q4\/noOffset.png\" alt=\"Model with 2 rates\">\r\n\r\n<p><strong>Sample Time Vector<\/strong><\/p>\r\n\r\n<p>What if I want the Gain block to execute at 0.4s, 1.4s, 2.4s, 3.4s, ... ?<\/p>\r\n\r\n<p>As described in documentation section <a href=\"https:\/\/www.mathworks.com\/help\/simulink\/ug\/how-to-specify-the-sample-time.html\">How to Specify the Sample Time<\/a>, you can specify a sample time vector in the form <tt>[Ts, To]<\/tt> where <tt>Ts<\/tt> is the sample time and <tt>To<\/tt> is the initial time offset.<\/p>\r\n\r\n<p>To apply an offset, I configure the Rate Transition:<\/p>\r\n\r\n<p><img decoding=\"async\" src=\"https:\/\/blogs.mathworks.com\/images\/seth\/2011Q4\/RateTransitionDialog.png\" alt=\"Configuring the Rate Transition to have an offset\">\r\n\r\n<p>and the model now gives a different result. We now see that the Gain executes at a sample time of 1s, but with an offset of 0.4:<\/p>\r\n\r\n<p><img decoding=\"async\" src=\"https:\/\/blogs.mathworks.com\/images\/seth\/2011Q4\/withOffset.png\" alt=\"Sample Time Offset\">\r\n\r\n<p><strong>Now it's your turn<\/strong><\/p>\r\n\r\n<p>Do you use sample time offset in your model? Leave us a <a href=\"https:\/\/blogs.mathworks.com\/seth\/?p=168&amp;#comment\">comment here<\/a>.<\/p>\r\n\r\n","protected":false},"excerpt":{"rendered":"<p>I noticed that many users are not aware that it is possible to specify sample time offsets in Simulink.\r\n\r\nScalar Sample Time\r\n\r\nIn this simple model, I have specified the sample time of the Constant... <a class=\"read-more\" href=\"https:\/\/blogs.mathworks.com\/simulink\/2011\/11\/20\/sample-time-offset\/\">read more >><\/a><\/p>","protected":false},"author":41,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":[],"categories":[30,10,33],"tags":[235,234],"_links":{"self":[{"href":"https:\/\/blogs.mathworks.com\/simulink\/wp-json\/wp\/v2\/posts\/168"}],"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=168"}],"version-history":[{"count":1,"href":"https:\/\/blogs.mathworks.com\/simulink\/wp-json\/wp\/v2\/posts\/168\/revisions"}],"predecessor-version":[{"id":7592,"href":"https:\/\/blogs.mathworks.com\/simulink\/wp-json\/wp\/v2\/posts\/168\/revisions\/7592"}],"wp:attachment":[{"href":"https:\/\/blogs.mathworks.com\/simulink\/wp-json\/wp\/v2\/media?parent=168"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blogs.mathworks.com\/simulink\/wp-json\/wp\/v2\/categories?post=168"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blogs.mathworks.com\/simulink\/wp-json\/wp\/v2\/tags?post=168"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}