{"id":15292,"date":"2023-09-27T13:07:04","date_gmt":"2023-09-27T17:07:04","guid":{"rendered":"https:\/\/blogs.mathworks.com\/simulink\/?p=15292"},"modified":"2023-09-27T13:07:04","modified_gmt":"2023-09-27T17:07:04","slug":"signals-vs-parameters-in-simulink-and-the-parameter-writer-block","status":"publish","type":"post","link":"https:\/\/blogs.mathworks.com\/simulink\/2023\/09\/27\/signals-vs-parameters-in-simulink-and-the-parameter-writer-block\/","title":{"rendered":"Signals vs Parameters in Simulink&#8230; and the Parameter Writer block"},"content":{"rendered":"<div class = rtcContent><div  style = 'margin: 2px 10px 9px 4px; padding: 0px; line-height: 21px; min-height: 0px; white-space: pre-wrap; color: rgb(0, 0, 0); font-family: Helvetica, Arial, sans-serif; font-style: normal; font-size: 14px; font-weight: 400; text-align: left; '><span>A colleague recently told me that he was often referring users to this blog post I wrote many years ago: <\/span><a href = \"https:\/\/blogs.mathworks.com\/simulink\/2011\/03\/08\/how-do-i-change-a-block-parameter-based-on-the-output-of-another-block\"><span>How Do I Change a Block Parameter Based on the Output of Another Block?<\/span><\/a><\/div><div  style = 'margin: 2px 10px 9px 4px; padding: 0px; line-height: 21px; min-height: 0px; white-space: pre-wrap; color: rgb(0, 0, 0); font-family: Helvetica, Arial, sans-serif; font-style: normal; font-size: 14px; font-weight: 400; text-align: left; '><span>Even if most of what I wrote in that post still holds today, I thought it would be a good idea to revisit this topic and describe how the <\/span><a href = \"https:\/\/www.mathworks.com\/help\/releases\/R2023b\/simulink\/slref\/parameterwriter.html\"><span>Parameter Writer<\/span><\/a><span> block modifies the game.<\/span><\/div><div  style = 'margin: 2px 10px 9px 4px; padding: 0px; line-height: 21px; min-height: 0px; white-space: pre-wrap; color: rgb(0, 0, 0); font-family: Helvetica, Arial, sans-serif; font-style: normal; font-size: 14px; font-weight: 400; text-align: left; '><span style=' font-weight: bold;'>Signals vs Parameters in Simulink<\/span><\/div><div  style = 'margin: 2px 10px 9px 4px; padding: 0px; line-height: 21px; min-height: 0px; white-space: pre-wrap; color: rgb(0, 0, 0); font-family: Helvetica, Arial, sans-serif; font-style: normal; font-size: 14px; font-weight: 400; text-align: left; '><span>In <\/span><a href = \"https:\/\/blogs.mathworks.com\/simulink\/2011\/03\/08\/how-do-i-change-a-block-parameter-based-on-the-output-of-another-block\"><span>How Do I Change a Block Parameter Based on the Output of Another Block?<\/span><\/a><span>, I tried to explain something fundamentally different between MATLAB and Simulink. In general, in MATLAB, all the data you create and operate on is stored in variables. You double-click on entries in the Workspace Browser, it opens the Variable Viewer to show the value:<\/span><\/div><div  style = 'margin: 2px 10px 9px 4px; padding: 0px; line-height: 21px; min-height: 0px; white-space: pre-wrap; color: rgb(0, 0, 0); font-family: Helvetica, Arial, sans-serif; font-style: normal; font-size: 14px; font-weight: 400; text-align: left; '><img class = \"imageNode\" src = \"https:\/\/blogs.mathworks.com\/simulink\/files\/ParameterWriter_1.png\" width = \"513\" height = \"214\" alt = \"\" style = \"vertical-align: baseline; width: 513px; height: 214px;\"><\/img><\/div><div  style = 'margin: 2px 10px 9px 4px; padding: 0px; line-height: 21px; min-height: 0px; white-space: pre-wrap; color: rgb(0, 0, 0); font-family: Helvetica, Arial, sans-serif; font-style: normal; font-size: 14px; font-weight: 400; text-align: left; '><span> In Simulink there are two types of data: <\/span><\/div><ul  style = 'margin: 10px 0px 20px; padding-left: 0px; font-family: Helvetica, Arial, sans-serif; font-size: 14px; '><li  style = 'margin-left: 56px; line-height: 21px; min-height: 0px; text-align: left; white-space: pre-wrap; '><span style=' font-weight: bold;'>Signals:<\/span><span> Represented by signal lines in the Simulink canvas, this type of data is expected to potentially change at every time step<\/span><\/li><li  style = 'margin-left: 56px; line-height: 21px; min-height: 0px; text-align: left; white-space: pre-wrap; '><span style=' font-weight: bold;'>Parameters:<\/span><span> Passed to Simulink blocks as MATLAB variables, this type of data is intended to remain constant or changes infrequently.<\/span><\/li><\/ul><div  style = 'margin: 2px 10px 9px 4px; padding: 0px; line-height: 21px; min-height: 0px; white-space: pre-wrap; color: rgb(0, 0, 0); font-family: Helvetica, Arial, sans-serif; font-style: normal; font-size: 14px; font-weight: 400; text-align: left; '><span>In many simple cases, the math ends up being the same. For example, using a <\/span><a href = \"https:\/\/www.mathworks.com\/help\/releases\/R2023b\/simulink\/slref\/add.html\"><span>Sum<\/span><\/a><span> block to add two signals gives the same results as using a <\/span><a href = \"https:\/\/www.mathworks.com\/help\/releases\/R2023b\/simulink\/slref\/bias.html\"><span>Bias<\/span><\/a><span> block if its parameter has the same value as the equivalent signal fed to the Sum block. In other words, those 3 are the same:<\/span><\/div><div  style = 'margin: 2px 10px 9px 4px; padding: 0px; line-height: 21px; min-height: 0px; white-space: pre-wrap; color: rgb(0, 0, 0); font-family: Helvetica, Arial, sans-serif; font-style: normal; font-size: 14px; font-weight: 400; text-align: left; '><img class = \"imageNode\" src = \"https:\/\/blogs.mathworks.com\/simulink\/files\/ParameterWriter_2.png\" width = \"907\" height = \"202\" alt = \"\" style = \"vertical-align: baseline; width: 907px; height: 202px;\"><\/img><\/div><div  style = 'margin: 2px 10px 9px 4px; padding: 0px; line-height: 21px; min-height: 0px; white-space: pre-wrap; color: rgb(0, 0, 0); font-family: Helvetica, Arial, sans-serif; font-style: normal; font-size: 14px; font-weight: 400; text-align: left; '><span>This raises the question: <\/span><span style=' font-style: italic;'>Why can I not make any block dialog parameter an input signal?<\/span><\/div><div  style = 'margin: 2px 10px 9px 4px; padding: 0px; line-height: 21px; min-height: 0px; white-space: pre-wrap; color: rgb(0, 0, 0); font-family: Helvetica, Arial, sans-serif; font-style: normal; font-size: 14px; font-weight: 400; text-align: left; '><span>My explanation is that some block algorithms are making assumptions that parameters will change infrequently. Changing those at every time step would lead to results that could be difficult to understand, or completely wrong depending on your assumptions.<\/span><\/div><div  style = 'margin: 2px 10px 9px 4px; padding: 0px; line-height: 21px; min-height: 0px; white-space: pre-wrap; color: rgb(0, 0, 0); font-family: Helvetica, Arial, sans-serif; font-style: normal; font-size: 14px; font-weight: 400; text-align: left; '><span>In the next two sections, I describe how to tune the value of dialog parameters for situations where this is appropriate, and I give one example where doing it can lead to confusing results.<\/span><\/div><h2  style = 'margin: 20px 10px 5px 4px; padding: 0px; line-height: 20px; min-height: 0px; white-space: pre-wrap; color: rgb(33, 33, 33); font-family: Helvetica, Arial, sans-serif; font-style: normal; font-size: 20px; font-weight: 700; text-align: left; '><span>What if I really want to change the value of a block parameter based on the output of another block?<\/span><\/h2><div  style = 'margin: 2px 10px 9px 4px; padding: 0px; line-height: 21px; min-height: 0px; white-space: pre-wrap; color: rgb(0, 0, 0); font-family: Helvetica, Arial, sans-serif; font-style: normal; font-size: 14px; font-weight: 400; text-align: left; '><span>Since my last post on this topic, we introduced the <\/span><a href = \"https:\/\/www.mathworks.com\/help\/releases\/R2023b\/simulink\/slref\/parameterwriter.html\"><span>Parameter Writer<\/span><\/a><span> block. For a few releases, the Parameter Writer block was restricted to be used only in very specific contexts where the execution order was explicitly defined. In R2023a, we relaxed this constraint and the Parameter Writer block can be used in many contexts. Internally, we analyze the data dependency and make sure the blocks execution order reflects it.<\/span><\/div><div  style = 'margin: 2px 10px 9px 4px; padding: 0px; line-height: 21px; min-height: 0px; white-space: pre-wrap; color: rgb(0, 0, 0); font-family: Helvetica, Arial, sans-serif; font-style: normal; font-size: 14px; font-weight: 400; text-align: left; '><span>To illustrate how the Parameter Writer block works, I decided to revisit another old blog post: <\/span><a href = \"https:\/\/blogs.mathworks.com\/simulink\/2011\/01\/18\/you-need-an-integrator-with-variable-limits-theres-a-solution-for-that\"><span>You need an integrator with variable limits\u2026 there\u2019s a solution for that!<\/span><\/a><\/div><div  style = 'margin: 2px 10px 9px 4px; padding: 0px; line-height: 21px; min-height: 0px; white-space: pre-wrap; color: rgb(0, 0, 0); font-family: Helvetica, Arial, sans-serif; font-style: normal; font-size: 14px; font-weight: 400; text-align: left; '><span>In this post, I pointed out the fact that the <\/span><a href = \"https:\/\/www.mathworks.com\/help\/releases\/R2023b\/simulink\/slref\/integrator.html\"><span>Integrator<\/span><\/a><span> block has an option to limit its output, but the limits can only be specified as dialog parameters:<\/span><\/div><div  style = 'margin: 2px 10px 9px 4px; padding: 0px; line-height: 21px; min-height: 0px; white-space: pre-wrap; color: rgb(0, 0, 0); font-family: Helvetica, Arial, sans-serif; font-style: normal; font-size: 14px; font-weight: 400; text-align: left; '><img class = \"imageNode\" src = \"https:\/\/blogs.mathworks.com\/simulink\/files\/ParameterWriter_3.png\" width = \"338\" height = \"437\" alt = \"\" style = \"vertical-align: baseline; width: 338px; height: 437px;\"><\/img><\/div><div  style = 'margin: 2px 10px 9px 4px; padding: 0px; line-height: 21px; min-height: 0px; white-space: pre-wrap; color: rgb(0, 0, 0); font-family: Helvetica, Arial, sans-serif; font-style: normal; font-size: 14px; font-weight: 400; text-align: left; '><span>At that time, the solution I found to limit the Integrator output using input signals was this complex contraption using the State and Reset ports of the Integrator:<\/span><\/div><div  style = 'margin: 2px 10px 9px 4px; padding: 0px; line-height: 21px; min-height: 0px; white-space: pre-wrap; color: rgb(0, 0, 0); font-family: Helvetica, Arial, sans-serif; font-style: normal; font-size: 14px; font-weight: 400; text-align: left; '><img class = \"imageNode\" src = \"https:\/\/blogs.mathworks.com\/simulink\/files\/ParameterWriter_4.png\" width = \"426\" height = \"250\" alt = \"\" style = \"vertical-align: baseline; width: 426px; height: 250px;\"><\/img><\/div><div  style = 'margin: 2px 10px 9px 4px; padding: 0px; line-height: 21px; min-height: 0px; white-space: pre-wrap; color: rgb(0, 0, 0); font-family: Helvetica, Arial, sans-serif; font-style: normal; font-size: 14px; font-weight: 400; text-align: left; '><span>As of MATLAB R2023a, if I am being asked to do the same, I would use two Parameter Writer blocks and bind them to the lower and upper saturation parameters of the Integrator block:<\/span><\/div><div  style = 'margin: 2px 10px 9px 4px; padding: 0px; line-height: 21px; min-height: 0px; white-space: pre-wrap; color: rgb(0, 0, 0); font-family: Helvetica, Arial, sans-serif; font-style: normal; font-size: 14px; font-weight: 400; text-align: left; '><img class = \"imageNode\" src = \"https:\/\/blogs.mathworks.com\/simulink\/files\/ParameterWriter_5.png\" width = \"867\" height = \"401\" alt = \"\" style = \"vertical-align: baseline; width: 867px; height: 401px;\"><\/img><\/div><div  style = 'margin: 2px 10px 9px 4px; padding: 0px; line-height: 21px; min-height: 0px; white-space: pre-wrap; color: rgb(0, 0, 0); font-family: Helvetica, Arial, sans-serif; font-style: normal; font-size: 14px; font-weight: 400; text-align: left; '><span>Here is an example model using the above subsystem, changing the integrator limits from +\/-10 to +\/-1 at t=50sec.<\/span><\/div><div  style = 'margin: 2px 10px 9px 4px; padding: 0px; line-height: 21px; min-height: 0px; white-space: pre-wrap; color: rgb(0, 0, 0); font-family: Helvetica, Arial, sans-serif; font-style: normal; font-size: 14px; font-weight: 400; text-align: left; '><img class = \"imageNode\" src = \"https:\/\/blogs.mathworks.com\/simulink\/files\/ParameterWriter_6.png\" width = \"927\" height = \"550\" alt = \"\" style = \"vertical-align: baseline; width: 927px; height: 550px;\"><\/img><\/div><h2  style = 'margin: 20px 10px 5px 4px; padding: 0px; line-height: 20px; min-height: 0px; white-space: pre-wrap; color: rgb(33, 33, 33); font-family: Helvetica, Arial, sans-serif; font-style: normal; font-size: 20px; font-weight: 700; text-align: left; '><span>Use at your own risk!<\/span><\/h2><div  style = 'margin: 2px 10px 9px 4px; padding: 0px; line-height: 21px; min-height: 0px; white-space: pre-wrap; color: rgb(0, 0, 0); font-family: Helvetica, Arial, sans-serif; font-style: normal; font-size: 14px; font-weight: 400; text-align: left; '><span>I heard somewhere that <\/span><a href = \"https:\/\/en.wikipedia.org\/wiki\/With_great_power_comes_great_responsibility\"><span>With great power comes great responsibility<\/span><\/a><span> and this applies here.<\/span><\/div><div  style = 'margin: 2px 10px 9px 4px; padding: 0px; line-height: 21px; min-height: 0px; white-space: pre-wrap; color: rgb(0, 0, 0); font-family: Helvetica, Arial, sans-serif; font-style: normal; font-size: 14px; font-weight: 400; text-align: left; '><span>The following is an example I receive every once in a while, where the user wants to progressively change the frequency of a Sine Wave block, let's say from 3 rad\/sec to 6 rad\/sec over 5 seconds. As you can see, the frequency of the resulting sine wave does not smoothly increase from 3 rad\/sec to 6 rad\/sec. Instead, it looks twice faster than expected.<\/span><\/div><div  style = 'margin: 2px 10px 9px 4px; padding: 0px; line-height: 21px; min-height: 0px; white-space: pre-wrap; color: rgb(0, 0, 0); font-family: Helvetica, Arial, sans-serif; font-style: normal; font-size: 14px; font-weight: 400; text-align: left; '><img class = \"imageNode\" src = \"https:\/\/blogs.mathworks.com\/simulink\/files\/ParameterWriter_7.png\" width = \"709\" height = \"227\" alt = \"\" style = \"vertical-align: baseline; width: 709px; height: 227px;\"><\/img><\/div><div  style = 'margin: 2px 10px 9px 4px; padding: 0px; line-height: 21px; min-height: 0px; white-space: pre-wrap; color: rgb(0, 0, 0); font-family: Helvetica, Arial, sans-serif; font-style: normal; font-size: 14px; font-weight: 400; text-align: left; '><span>If the reason is not obvious to you, I recommend reading <\/span><a href = \"https:\/\/www.mathworks.com\/matlabcentral\/answers\/217746-implementing-a-sine-wave-with-linearly-changing-frequency\"><span>this MATLAB answer<\/span><\/a><span>. <\/span><\/div><div  style = 'margin: 2px 10px 9px 4px; padding: 0px; line-height: 21px; min-height: 0px; white-space: pre-wrap; color: rgb(0, 0, 0); font-family: Helvetica, Arial, sans-serif; font-style: normal; font-size: 14px; font-weight: 400; text-align: left; '><span>Exemplifying what I described above, the <\/span><a href = \"https:\/\/www.mathworks.com\/help\/releases\/R2023b\/simulink\/slref\/sinewave.html\"><span>Sine Wave<\/span><\/a><span> block makes the assumption that the frequency is constant. Based on this assumption, instead of integrating the time-varying frequency and computing the angle to be passed to <\/span><span style=' font-family: monospace;'>sin<\/span><span>:<\/span><\/div><div  style = 'margin: 2px 10px 9px 4px; padding: 0px; line-height: 21px; min-height: 0px; white-space: pre-wrap; color: rgb(0, 0, 0); font-family: Helvetica, Arial, sans-serif; font-style: normal; font-size: 14px; font-weight: 400; text-align: center; '><span mathmlencoding=\"&lt;math xmlns=&quot;http:\/\/www.w3.org\/1998\/Math\/MathML&quot; display=&quot;block&quot;&gt;&lt;mrow&gt;&lt;mi mathvariant=&quot;italic&quot;&gt;y&lt;\/mi&gt;&lt;mo&gt;=&lt;\/mo&gt;&lt;mi mathvariant=&quot;normal&quot;&gt;sin&lt;\/mi&gt;&lt;mrow&gt;&lt;mo&gt;(&lt;\/mo&gt;&lt;mrow&gt;&lt;mrow&gt;&lt;mo&gt;\u222b&lt;\/mo&gt;&lt;mrow&gt;&lt;mi&gt;\u03c9&lt;\/mi&gt;&lt;mrow&gt;&lt;mo&gt;(&lt;\/mo&gt;&lt;mrow&gt;&lt;mi mathvariant=&quot;italic&quot;&gt;t&lt;\/mi&gt;&lt;\/mrow&gt;&lt;mo&gt;)&lt;\/mo&gt;&lt;\/mrow&gt;&lt;mi mathvariant=&quot;normal&quot;&gt;dt&lt;\/mi&gt;&lt;\/mrow&gt;&lt;\/mrow&gt;&lt;\/mrow&gt;&lt;mo&gt;)&lt;\/mo&gt;&lt;\/mrow&gt;&lt;\/mrow&gt;&lt;\/math&gt;\" style=\"vertical-align:-14px\"><math xmlns=\"http:\/\/www.w3.org\/1998\/Math\/MathML\" display=\"block\"><mrow><mi mathvariant=\"italic\">y<\/mi><mo>=<\/mo><mi mathvariant=\"normal\">sin<\/mi><mrow><mo>(<\/mo><mrow><mrow><mo>\u222b<\/mo><mrow><mi>\u03c9<\/mi><mrow><mo>(<\/mo><mrow><mi mathvariant=\"italic\">t<\/mi><\/mrow><mo>)<\/mo><\/mrow><mi mathvariant=\"normal\">dt<\/mi><\/mrow><\/mrow><\/mrow><mo>)<\/mo><\/mrow><\/mrow><\/math><\/span><\/div><div  style = 'margin: 2px 10px 9px 4px; padding: 0px; line-height: 21px; min-height: 0px; white-space: pre-wrap; color: rgb(0, 0, 0); font-family: Helvetica, Arial, sans-serif; font-style: normal; font-size: 14px; font-weight: 400; text-align: left; '><span>The Sine Wave block assumes a constant value for <\/span><span style=\"font-family: STIXGeneral-webfont, serif; font-style: italic; font-weight: 400; color: rgb(0, 0, 0);\">\u03c9<\/span><span> <\/span><span style=' font-family: monospace;'>and <\/span><span>implements:<\/span><\/div><div  style = 'margin: 2px 10px 9px 4px; padding: 0px; line-height: 21px; min-height: 0px; white-space: pre-wrap; color: rgb(0, 0, 0); font-family: Helvetica, Arial, sans-serif; font-style: normal; font-size: 14px; font-weight: 400; text-align: center; '><span mathmlencoding=\"&lt;math xmlns=&quot;http:\/\/www.w3.org\/1998\/Math\/MathML&quot; display=&quot;block&quot;&gt;&lt;mrow&gt;&lt;mi mathvariant=&quot;italic&quot;&gt;y&lt;\/mi&gt;&lt;mo&gt;=&lt;\/mo&gt;&lt;mi mathvariant=&quot;normal&quot;&gt;sin&lt;\/mi&gt;&lt;mrow&gt;&lt;mo&gt;(&lt;\/mo&gt;&lt;mrow&gt;&lt;mi&gt;\u03c9&lt;\/mi&gt;&lt;mo&gt;*&lt;\/mo&gt;&lt;mi mathvariant=&quot;italic&quot;&gt;t&lt;\/mi&gt;&lt;\/mrow&gt;&lt;mo&gt;)&lt;\/mo&gt;&lt;\/mrow&gt;&lt;\/mrow&gt;&lt;\/math&gt;\" style=\"vertical-align:-5px\"><math xmlns=\"http:\/\/www.w3.org\/1998\/Math\/MathML\" display=\"block\"><mrow><mi mathvariant=\"italic\">y<\/mi><mo>=<\/mo><mi mathvariant=\"normal\">sin<\/mi><mrow><mo>(<\/mo><mrow><mi>\u03c9<\/mi><mo>*<\/mo><mi mathvariant=\"italic\">t<\/mi><\/mrow><mo>)<\/mo><\/mrow><\/mrow><\/math><\/span><\/div><div  style = 'margin: 2px 10px 9px 4px; padding: 0px; line-height: 21px; min-height: 0px; white-space: pre-wrap; color: rgb(0, 0, 0); font-family: Helvetica, Arial, sans-serif; font-style: normal; font-size: 14px; font-weight: 400; text-align: left; '><span>Making <\/span><span style=\"font-family: STIXGeneral-webfont, serif; font-style: italic; font-weight: 400; color: rgb(0, 0, 0);\">\u03c9<\/span><span> increase linearly with time (<\/span><span mathmlencoding=\"&lt;math xmlns=&quot;http:\/\/www.w3.org\/1998\/Math\/MathML&quot; display=&quot;inline&quot;&gt;&lt;mrow&gt;&lt;mi&gt;\u03c9&lt;\/mi&gt;&lt;mrow&gt;&lt;mo&gt;(&lt;\/mo&gt;&lt;mrow&gt;&lt;mi mathvariant=&quot;italic&quot;&gt;t&lt;\/mi&gt;&lt;\/mrow&gt;&lt;mo&gt;)&lt;\/mo&gt;&lt;\/mrow&gt;&lt;mo&gt;=&lt;\/mo&gt;&lt;mi mathvariant=&quot;italic&quot;&gt;k&lt;\/mi&gt;&lt;mo&gt;*&lt;\/mo&gt;&lt;mi mathvariant=&quot;italic&quot;&gt;t&lt;\/mi&gt;&lt;\/mrow&gt;&lt;\/math&gt;\" style=\"vertical-align:-5px\"><math xmlns=\"http:\/\/www.w3.org\/1998\/Math\/MathML\" display=\"inline\"><mrow><mi>\u03c9<\/mi><mrow><mo>(<\/mo><mrow><mi mathvariant=\"italic\">t<\/mi><\/mrow><mo>)<\/mo><\/mrow><mo>=<\/mo><mi mathvariant=\"italic\">k<\/mi><mo>*<\/mo><mi mathvariant=\"italic\">t<\/mi><\/mrow><\/math><\/span><span>) and differentiating the result shows why the resulting function is twice the desired frequency:<\/span><\/div><div  style = 'margin: 2px 10px 9px 4px; padding: 0px; line-height: 21px; min-height: 0px; white-space: pre-wrap; color: rgb(0, 0, 0); font-family: Helvetica, Arial, sans-serif; font-style: normal; font-size: 14px; font-weight: 400; text-align: center; '><span mathmlencoding=\"&lt;math xmlns=&quot;http:\/\/www.w3.org\/1998\/Math\/MathML&quot; display=&quot;block&quot;&gt;&lt;mrow&gt;&lt;mrow&gt;&lt;mfrac&gt;&lt;mrow&gt;&lt;mi mathvariant=&quot;normal&quot;&gt;d&lt;\/mi&gt;&lt;\/mrow&gt;&lt;mrow&gt;&lt;mi mathvariant=&quot;normal&quot;&gt;d&lt;\/mi&gt;&lt;mrow&gt;&lt;mi mathvariant=&quot;italic&quot;&gt;t&lt;\/mi&gt;&lt;\/mrow&gt;&lt;\/mrow&gt;&lt;\/mfrac&gt;&lt;mrow&gt;&lt;mrow&gt;&lt;mo&gt;(&lt;\/mo&gt;&lt;mrow&gt;&lt;mi mathvariant=&quot;italic&quot;&gt;k&lt;\/mi&gt;&lt;mo&gt;*&lt;\/mo&gt;&lt;mi mathvariant=&quot;italic&quot;&gt;t&lt;\/mi&gt;&lt;mo&gt;*&lt;\/mo&gt;&lt;mi mathvariant=&quot;italic&quot;&gt;t&lt;\/mi&gt;&lt;\/mrow&gt;&lt;mo&gt;)&lt;\/mo&gt;&lt;\/mrow&gt;&lt;\/mrow&gt;&lt;\/mrow&gt;&lt;mo&gt;=&lt;\/mo&gt;&lt;mn&gt;2&lt;\/mn&gt;&lt;mo&gt;*&lt;\/mo&gt;&lt;mi mathvariant=&quot;italic&quot;&gt;k&lt;\/mi&gt;&lt;mo&gt;*&lt;\/mo&gt;&lt;mi mathvariant=&quot;italic&quot;&gt;t&lt;\/mi&gt;&lt;\/mrow&gt;&lt;\/math&gt;\" style=\"vertical-align:-15px\"><math xmlns=\"http:\/\/www.w3.org\/1998\/Math\/MathML\" display=\"block\"><mrow><mrow><mfrac><mrow><mi mathvariant=\"normal\">d<\/mi><\/mrow><mrow><mi mathvariant=\"normal\">d<\/mi><mrow><mi mathvariant=\"italic\">t<\/mi><\/mrow><\/mrow><\/mfrac><mrow><mrow><mo>(<\/mo><mrow><mi mathvariant=\"italic\">k<\/mi><mo>*<\/mo><mi mathvariant=\"italic\">t<\/mi><mo>*<\/mo><mi mathvariant=\"italic\">t<\/mi><\/mrow><mo>)<\/mo><\/mrow><\/mrow><\/mrow><mo>=<\/mo><mn>2<\/mn><mo>*<\/mo><mi mathvariant=\"italic\">k<\/mi><mo>*<\/mo><mi mathvariant=\"italic\">t<\/mi><\/mrow><\/math><\/span><\/div><div  style = 'margin: 2px 10px 9px 4px; padding: 0px; line-height: 21px; min-height: 0px; white-space: pre-wrap; color: rgb(0, 0, 0); font-family: Helvetica, Arial, sans-serif; font-style: normal; font-size: 14px; font-weight: 400; text-align: left; '><span>To get the desired frequency-increasing sine wave, you want to integrate the time-varying frequency:<\/span><\/div><div  style = 'margin: 2px 10px 9px 4px; padding: 0px; line-height: 21px; min-height: 0px; white-space: pre-wrap; color: rgb(0, 0, 0); font-family: Helvetica, Arial, sans-serif; font-style: normal; font-size: 14px; font-weight: 400; text-align: left; '><img class = \"imageNode\" src = \"https:\/\/blogs.mathworks.com\/simulink\/files\/ParameterWriter_8.png\" width = \"753\" height = \"216\" alt = \"\" style = \"vertical-align: baseline; width: 753px; height: 216px;\"><\/img><\/div><div  style = 'margin: 2px 10px 9px 4px; padding: 0px; line-height: 21px; min-height: 0px; white-space: pre-wrap; color: rgb(0, 0, 0); font-family: Helvetica, Arial, sans-serif; font-style: normal; font-size: 14px; font-weight: 400; text-align: left; '><span>Another tip here... if you implement this model, I recommend enabling the Wrap State option of the Integrator block. This will avoid its output to grow infinitely as the simulation time increases, which could lead to numerical issues for long simulations:<\/span><\/div><div  style = 'margin: 2px 10px 9px 4px; padding: 0px; line-height: 21px; min-height: 0px; white-space: pre-wrap; color: rgb(0, 0, 0); font-family: Helvetica, Arial, sans-serif; font-style: normal; font-size: 14px; font-weight: 400; text-align: left; '><img class = \"imageNode\" src = \"https:\/\/blogs.mathworks.com\/simulink\/files\/ParameterWriter_9.png\" width = \"630\" height = \"194\" alt = \"\" style = \"vertical-align: baseline; width: 630px; height: 194px;\"><\/img><\/div><div  style = 'margin: 2px 10px 9px 4px; padding: 0px; line-height: 21px; min-height: 0px; white-space: pre-wrap; color: rgb(0, 0, 0); font-family: Helvetica, Arial, sans-serif; font-style: normal; font-size: 14px; font-weight: 400; text-align: left; '><span>Because of these types of subtleties, I recommend using the Parameter Writer block only in contexts where it is executed only infrequently. This could be for example in a <\/span><a href = \"https:\/\/www.mathworks.com\/help\/releases\/R2023b\/simulink\/slref\/triggeredsubsystem.html\"><span>Triggered Subsystem<\/span><\/a><span>, <\/span><a href = \"https:\/\/www.mathworks.com\/help\/releases\/R2023b\/simulink\/slref\/functioncallsubsystem.html\"><span>Function-Call Subsystem<\/span><\/a><span>, <\/span><a href = \"https:\/\/www.mathworks.com\/help\/releases\/R2023b\/simulink\/slref\/initializefunction.html\"><span>Initialize Function<\/span><\/a><span>, etc.<\/span><\/div><h2  style = 'margin: 20px 10px 5px 4px; padding: 0px; line-height: 20px; min-height: 0px; white-space: pre-wrap; color: rgb(33, 33, 33); font-family: Helvetica, Arial, sans-serif; font-style: normal; font-size: 20px; font-weight: 700; text-align: left; '><span>Now it's your turn<\/span><\/h2><div  style = 'margin: 2px 10px 9px 4px; padding: 0px; line-height: 21px; min-height: 0px; white-space: pre-wrap; color: rgb(0, 0, 0); font-family: Helvetica, Arial, sans-serif; font-style: normal; font-size: 14px; font-weight: 400; text-align: left; '><span>Are you a fan of the Parameter Writer block? Do you have challenges with this concept of \"Signal vs Parameters\" in Simulink? Let us know in the comments below.<\/span><\/div><div  style = 'margin: 2px 10px 9px 4px; padding: 0px; line-height: 21px; min-height: 0px; white-space: pre-wrap; color: rgb(0, 0, 0); font-family: Helvetica, Arial, sans-serif; font-style: normal; font-size: 14px; font-weight: 400; text-align: left; '><a href = \"https:\/\/matlab.mathworks.com\/open\/github\/v1?repo=simulink\/blog&amp;file=2023_09_27_ParameterWriter\/ParameterWriter.mlx\"><img class = \"imageNode\" src = \"https:\/\/blogs.mathworks.com\/simulink\/files\/ParameterWriter_10.png\" width = \"136\" height = \"21\" alt = \"\" style = \"vertical-align: baseline; width: 136px; height: 21px;\"><\/img><\/a><\/div>\r\n<\/div><script type=\"text\/javascript\">var css = ''; var head = document.head || document.getElementsByTagName('head')[0], style = document.createElement('style'); head.appendChild(style); style.type = 'text\/css'; if (style.styleSheet){ style.styleSheet.cssText = css; } else { style.appendChild(document.createTextNode(css)); }<\/script>","protected":false},"excerpt":{"rendered":"<div class=\"overview-image\"><img src=\"https:\/\/blogs.mathworks.com\/simulink\/files\/ParameterWriter_7.png\" class=\"img-responsive attachment-post-thumbnail size-post-thumbnail wp-post-image\" alt=\"\" decoding=\"async\" loading=\"lazy\" \/><\/div><p>A colleague recently told me that he was often referring users to this blog post I wrote many years ago: How Do I Change a Block Parameter Based on the Output of Another Block?Even if most of what I... <a class=\"read-more\" href=\"https:\/\/blogs.mathworks.com\/simulink\/2023\/09\/27\/signals-vs-parameters-in-simulink-and-the-parameter-writer-block\/\">read more >><\/a><\/p>","protected":false},"author":41,"featured_media":15280,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":[],"categories":[69,11,33,16],"tags":[],"_links":{"self":[{"href":"https:\/\/blogs.mathworks.com\/simulink\/wp-json\/wp\/v2\/posts\/15292"}],"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=15292"}],"version-history":[{"count":1,"href":"https:\/\/blogs.mathworks.com\/simulink\/wp-json\/wp\/v2\/posts\/15292\/revisions"}],"predecessor-version":[{"id":15295,"href":"https:\/\/blogs.mathworks.com\/simulink\/wp-json\/wp\/v2\/posts\/15292\/revisions\/15295"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/blogs.mathworks.com\/simulink\/wp-json\/wp\/v2\/media\/15280"}],"wp:attachment":[{"href":"https:\/\/blogs.mathworks.com\/simulink\/wp-json\/wp\/v2\/media?parent=15292"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blogs.mathworks.com\/simulink\/wp-json\/wp\/v2\/categories?post=15292"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blogs.mathworks.com\/simulink\/wp-json\/wp\/v2\/tags?post=15292"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}