title: How to define a dynamic array in Simulink using MATLAB function and Model Explorer
body: <p>I am working on a MATLAB Simulink design and I am stucked on a problem. I would like to create a an dynamic uint8 array whose length is random. To do this, I have created a Matlab function and defined the variable as:</p>
  <pre><code>len = 100;
  ethMesg = ones([1,len], 'uint8');
  </code></pre>
  <p>Note: Len is going to a random integer in future.</p>
  <p>Later, I have opened the Model Explorer and set it as:</p>
  <p><a href="https://i.stack.imgur.com/69e85.png" rel="nofollow noreferrer">enter image description here</a></p>
  <p>So, basically I checked the Variable size box and set a limit as 1 to 1514 (1x1514) because MATLAB Simulink asks for an upper limit. When I try to build the model (CTRL + D) the error below returns.</p>
  <blockquote>
  <p>Expression '[1 1514]' for maximum of data 'ethMesg' must evaluate to a
  scalar.</p>
  </blockquote>
  <p>I think Simulink thinks this variable as a scalar and does not acccept a vector definition in Model Explorer (1 x 1514). Does anyone knows how to make sure that a variable is defined as a vector, or am I doing something wrong because this variable makes problem for the last 2 days.</p>
  <p>Btw, do I have to check the &quot;varied size&quot; box to define a varied variable because otherwise Simulink asks for a specific size?</p>
  <p>Thanks for your help.</p>