{"id":69,"date":"2009-10-16T19:00:42","date_gmt":"2009-10-16T19:00:42","guid":{"rendered":"https:\/\/blogs.mathworks.com\/seth\/2009\/10\/16\/radar-tracking-in-simulink-variable-size-signals\/"},"modified":"2009-10-16T21:07:40","modified_gmt":"2009-10-16T21:07:40","slug":"radar-tracking-in-simulink-variable-size-signals","status":"publish","type":"post","link":"https:\/\/blogs.mathworks.com\/simulink\/2009\/10\/16\/radar-tracking-in-simulink-variable-size-signals\/","title":{"rendered":"Radar Tracking in Simulink: Variable Size Signals"},"content":{"rendered":"This week I welcome guest blogger Aarti Ramani to talk about a long requested feature, variable size signals in Simulink.\r\n\r\n<img decoding=\"async\" src=\"https:\/\/blogs.mathworks.com\/images\/seth\/2009Q4\/Aarti_Ramani.jpg\" alt=\"Aarti Ramani\" \/>\r\n\r\n<p>Depending on target ranges, radar systems operate in\r\ndifferent modes (different lengths of data etc). \u00a0Let\u2019s assume we have two\r\nplanes at two different altitudes. Now, what happens if there is a new plane in\r\nsight? Since the number of targets being detected by the radar is now changing,\r\nhow would you use Simulink to add this plane to its tracking list? <\/p>\r\n\r\n<p><img decoding=\"async\" src=\"https:\/\/blogs.mathworks.com\/images\/seth\/2009Q4\/radar_length_mode.png\" alt=\"Radar mode and length\"><\/p>\r\n\r\n<p>A short and simple answer to this question is: <a\r\nhref=\"https:\/\/www.mathworks.com\/help\/releases\/R2009b\/toolbox\/simulink\/ug\/br4lzsy.html\">Variable\r\nSize Signals<\/a>. <\/p>\r\n\r\n<p>I\u2019ve read many customer requests wanting to be able to\r\nchange the dimensions of their Simulink variables while the simulation runs. Be\r\nit a radar system which needs to operate in different modes based on its target\r\nrange to a simple combustion engine that needs to change its frame size based\r\non the number of samples per cycle, each of these system dynamics work with\r\nsignals whose sizes change during model execution.<\/p>\r\n\r\n<p>Although, earlier I had to tell our customers that Simulink\r\ndid not have this capacity and you could not change a model\u2019s signals\r\ndimensions during execution; with R2009b, Simulink now supports variable-size\r\ninputs and outputs in over 40 Simulink blocks.<\/p>\r\n\r\n<p><strong>How does one create a variable size signal? <\/strong><\/p>\r\n\r\n<p>There are several methods of creating a variable size\r\nsignal:\u00a0 Switch blocks; Multi-Switch blocks with different input sizes; a Selector\r\nblock indexing options or custom code blocks (S-functions and Embedded MATLAB\r\nblocks). <\/p>\r\n\r\n<p>A common way of generating variable-size signals is to use a\r\nSwitch block for which each of the input signals differ in size. The Switch\r\nBlock now allows variable size signals to be passed in as inputs: <\/p>\r\n\r\n<p><img decoding=\"async\" src=\"https:\/\/blogs.mathworks.com\/images\/seth\/2009Q4\/switchBlockParams.png\" alt=\"Block parameters for the Switch Block\"><\/p>\r\n\r\n<p>By simply selecting the option \u201cAllow different data input\r\nsizes\u201d, you can obtain a variable size output signal whose dimensions change\r\nwith time.<\/p>\r\n\r\n<p>As an\r\nexperiment, let us look at a simple demo model \u201csldemo_varsize_basic.mdl\u201d. This demonstration\r\ncontains examples of how to use variable-size signals in a Simulink model, and\r\nto show what kind of operations you can apply to them.<\/p>\r\n\r\n<p><img decoding=\"async\" src=\"https:\/\/blogs.mathworks.com\/images\/seth\/2009Q4\/varSizeBasic_diagram.png\" alt=\"Variable size signals in a Simulink diagram.\"><\/span><\/p>\r\n\r\n<p>Look at\r\nhow the Switch block, allowing 2 inputs of different dimensions, can be used\r\nfor operations like addition, vector concatenation etc.<\/p>\r\n\r\n<p>You can also use the\r\n\u201cSelector\u201d blocks to create a variable size signal. The Selector block generates as\r\noutput selected or reordered elements of an input vector, matrix, or\r\nmultidimensional signal. Using the \u201cStarting and ending indices (port)\u201d\r\nindexing option, you can allow inputs of variable dimensions to generate\r\nvariable size signals.<\/p>\r\n\r\n<p><img decoding=\"async\" src=\"https:\/\/blogs.mathworks.com\/images\/seth\/2009Q4\/selectorBlockParams.png\" alt=\"Selector block parameters\"><\/span><\/p>\r\n\r\n<p>You can use the Selector block to subreferece a matrix as shown below:<\/p>\r\n\r\n<p><img decoding=\"async\" src=\"https:\/\/blogs.mathworks.com\/images\/seth\/2009Q4\/varSizeBasic_selector.png\" alt=\"Variable size signals from the selector block\"><\/span><\/p>\r\n\r\n<p><strong>How can I get the current dimensions or width of a\r\nvariable-size signal?<\/strong><\/p>\r\n\r\n<p>You can use the Probe block to output the width of a signal.\r\n<\/p>\r\n\r\n<p><img decoding=\"async\" src=\"https:\/\/blogs.mathworks.com\/images\/seth\/2009Q4\/probeBlockParams.png\" alt=\"Probe block parameters\"><\/p>\r\n\r\n<p>The Probe\r\nallows you to visualize and save the signal dimensions and view the I\/O and\r\nstate data for blocks selected.\u00a0 This could also be used in a calculation that\r\nrequires sample size information.<\/p>\r\n\r\n<p><strong>How can I convert a variable-size signal into a\r\nfixed-size signal?<\/strong><\/p>\r\n\r\n<p>To convert a variable size signal into a fixed size signal,\r\nyou can use the \u201cAssignment\u201d block. \u00a0The variable-size signal feeds into the second\r\ninput port of the Assignment block and can be used to convert the incoming\r\nsignal into a fixed size signal. <\/p>\r\n\r\n<p>By allowing signal sizes in Simulink models to vary during\r\nexecution, one can easily model systems with varying environments, resources,\r\nand constraints. So, coming back to our radar system, using variable size\r\nsignals, you can now create a conceptual air traffic control (ATC) radar\r\nsimulation based on your radar range equation(s):<\/p>\r\n\r\n<p><img decoding=\"async\" src=\"https:\/\/blogs.mathworks.com\/images\/seth\/2009Q4\/aero_atc.png\" alt=\"Simulink radar model\"><\/p>\r\n\r\n<p>For more details on how this snazzy feature works, check out\r\nthe <a\r\nhref=\"https:\/\/www.mathworks.com\/help\/releases\/R2009b\/toolbox\/simulink\/ug\/br4lzsy.html\">Variable\r\nSizing documentation<\/a>.<\/p>\r\n\r\n<p><strong>Now it\u2019s your turn<\/strong><\/p>\r\n\r\n<p>Do you plan to upgrade to R2009b and use variable size signals?\u00a0\r\nLeave a <a href=\"https:\/\/blogs.mathworks.com\/seth\/?p=69&#comment\">comment here<\/a> and tell me what you plan to model.<\/p>\r\n","protected":false},"excerpt":{"rendered":"<p>This week I welcome guest blogger Aarti Ramani to talk about a long requested feature, variable size signals in Simulink.\r\n\r\n\r\n\r\nDepending on target ranges, radar systems operate in\r\ndifferent modes... <a class=\"read-more\" href=\"https:\/\/blogs.mathworks.com\/simulink\/2009\/10\/16\/radar-tracking-in-simulink-variable-size-signals\/\">read more >><\/a><\/p>","protected":false},"author":40,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":[],"categories":[65,73,11,16],"tags":[108,441],"_links":{"self":[{"href":"https:\/\/blogs.mathworks.com\/simulink\/wp-json\/wp\/v2\/posts\/69"}],"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=69"}],"version-history":[{"count":0,"href":"https:\/\/blogs.mathworks.com\/simulink\/wp-json\/wp\/v2\/posts\/69\/revisions"}],"wp:attachment":[{"href":"https:\/\/blogs.mathworks.com\/simulink\/wp-json\/wp\/v2\/media?parent=69"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blogs.mathworks.com\/simulink\/wp-json\/wp\/v2\/categories?post=69"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blogs.mathworks.com\/simulink\/wp-json\/wp\/v2\/tags?post=69"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}