{"id":35,"date":"2008-10-24T10:30:57","date_gmt":"2008-10-24T15:30:57","guid":{"rendered":"https:\/\/blogs.mathworks.com\/seth\/2008\/10\/24\/r2008b-simulink-sample-time-colors\/"},"modified":"2008-10-24T10:38:35","modified_gmt":"2008-10-24T15:38:35","slug":"r2008b-simulink-sample-time-colors","status":"publish","type":"post","link":"https:\/\/blogs.mathworks.com\/simulink\/2008\/10\/24\/r2008b-simulink-sample-time-colors\/","title":{"rendered":"R2008b Simulink: Sample Time Colors"},"content":{"rendered":"<p>Simulink models present a schematic layout of your algorithm.\u00a0\r\nThe diagram encodes information about the system in the form of block icons,\r\ndata type annotations, and sample time colors.\u00a0 In technical support, I have\r\nseen many questions like,<\/p>\r\n\r\n<ul>\r\n    <li>How can I print on a black and white printer and show sample time\r\n    information?<\/li>\r\n    <li>What is the sample time of the green signal?<\/li>\r\n    <li>Why does Simulink have so few sample time colors?<\/li>\r\n<\/ul>\r\n\r\n<p>In this post, I will to show you some new R2008b features that\r\nmake it easier to understand what rates are in your model and make it easier to\r\ndocument your design.\u00a0 I will also unravel the mystery of why Simulink has so\r\nfew sample time colors.<\/p>\r\n\r\n<p><strong>Sample Time Annotations<\/strong><\/p>\r\n\r\n<p>For a long time Simulink has offered a Format menu option to\r\nturn on the sample time colors.\u00a0 This labels blocks and signals with different\r\ncolors based on their update rate.\u00a0 Red for the fastest discrete rate, green\r\nfor the second fastest, black for continuous, and many more.\u00a0 The documentation\r\nhas a table of <a\r\nhref=\"https:\/\/www.mathworks.com\/help\/releases\/R2008b\/toolbox\/simulink\/ug\/brrdmmw-1.html#brrdmmw-14\">sample\r\ntime colors<\/a> and their meaning.\u00a0 After updating the diagram (Ctrl-D), these\r\ncolors show you which blocks have the same rates in your model.\u00a0 In Simulink R2008b,\r\nyou can choose to show the sample time colors as well as sample time\r\nannotations.<\/p>\r\n\r\n<p><img decoding=\"async\" src=\"https:\/\/blogs.mathworks.com\/images\/seth\/2008Q4\/sampleTimeColorsMenu.png\" alt=\"Simulink R2008b sample time colors menu\"><\/p>\r\n\r\n<p>The annotations add text\u00a0 to the diagram that identifies\r\nrates as D1, D2, D3, Cont, Inf, etc.\u00a0 This is a great reminder when your model\r\nhas many rates in it.\u00a0 Now you can print your model on a black and white\r\nprinter and keep the rate information visible in the form of annotations.<\/p>\r\n\r\n<p><img decoding=\"async\" src=\"https:\/\/blogs.mathworks.com\/images\/seth\/2008Q4\/sampleTimeColorsAnnotation.png\" alt=\"Simulink diagram with R2008b sample time annotations\"><\/p>\r\n\r\n<p><strong>The Sample Time Legend<\/strong><\/p>\r\n\r\n<p>To help decode the meaning of these annotations and the\r\ncolors, we have added the <a\r\nhref=\"https:\/\/www.mathworks.com\/help\/releases\/R2008b\/toolbox\/simulink\/ug\/brrdmmw-1.html#brr1dbd\">Sample\r\nTime Legend<\/a>.\u00a0 This opens when you first enable the Sample Time Display\r\noptions, and is also found through the View-&gt;Sample Time Legend menu.<\/p>\r\n\r\n<p><img decoding=\"async\" src=\"https:\/\/blogs.mathworks.com\/images\/seth\/2008Q4\/sampleTimeLegend.png\" alt=\"Simulink R2008b sample time legend\"><\/p>\r\n\r\n<p>The annotation labels show you the meaning of the color and\r\ninclude the value of the sample time for that model.\u00a0 In previous releases, you\r\ncould only get a list of sample times in the model using debugger commands.\u00a0\r\nFor example:<\/p>\r\n\r\n<code style='font-size:11.0pt'>>> sim(bdroot,[],simset(<span style='color:#A020F0'>'Debug'<\/span>,{<span style='color:#A020F0'>'stimes'<\/span>,<span style='color:#A020F0'>'stop'<\/span>}))<br>\r\n%----------------------------------------------------------------%<br>\r\n[TM = 0                      ] stcDemo.Simulate<br>\r\n(sldebug @0): <br>\r\n--- Sample times  for 'stcDemo' [Number of sample times = 4]<br>\r\n  1. [0     , 0     ]  tid=0 (continuous sample time)<br>\r\n  2. [0.05  , 0     ]  tid=1<br>\r\n  3. [0.1   , 0     ]  tid=2<br>\r\n  4. [0.2   , 0     ]  tid=3<br>\r\n<br>\r\n(sldebug @0):<br>\r\n%----------------------------------------------------------------%<br>\r\n% Simulation stopped<br>\r\n<\/code>\r\n\r\n<p><strong>Why so few sample time colors?<\/strong><\/p>\r\n\r\n<p>Simulink graphics originally (circa 1992) had a minimum\r\n16-color graphics environment, including X terminals and Windows 3.0. This\r\nmeant that the lowest common denominator had to work. All the color stuff was\r\nhard-coded into the sample time code, so even when 32-bit core color support\r\nwas added circa R12-R13, the sample time code was not updated. The addition of\r\nannotations and a sample time legend are part of a much larger project in\r\nrecent releases to improve the use of color in Simulink.<\/p>\r\n\r\n<p>Do you have sample time colors turned on in your models? \u00a0Leave\r\na <a href=\"https:\/\/blogs.mathworks.com\/seth\/?p=35&amp;#comment\">comment<\/a> and\r\ntell me what you think about this new feature.<\/p>","protected":false},"excerpt":{"rendered":"<p>Simulink models present a schematic layout of your algorithm.\u00a0\r\nThe diagram encodes information about the system in the form of block icons,\r\ndata type annotations, and sample time colors.\u00a0 In... <a class=\"read-more\" href=\"https:\/\/blogs.mathworks.com\/simulink\/2008\/10\/24\/r2008b-simulink-sample-time-colors\/\">read more >><\/a><\/p>","protected":false},"author":40,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":[],"categories":[7,33,16],"tags":[62,60,61,441,59],"_links":{"self":[{"href":"https:\/\/blogs.mathworks.com\/simulink\/wp-json\/wp\/v2\/posts\/35"}],"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=35"}],"version-history":[{"count":0,"href":"https:\/\/blogs.mathworks.com\/simulink\/wp-json\/wp\/v2\/posts\/35\/revisions"}],"wp:attachment":[{"href":"https:\/\/blogs.mathworks.com\/simulink\/wp-json\/wp\/v2\/media?parent=35"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blogs.mathworks.com\/simulink\/wp-json\/wp\/v2\/categories?post=35"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blogs.mathworks.com\/simulink\/wp-json\/wp\/v2\/tags?post=35"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}