poster
2019-11-26, 16:43
<p>I would like to pass an uint8 array to my S-Function as a parameter:</p>
<pre><code>inParam = char(uint8(1:7))
</code></pre>
<p>In the S-Function I did the followings</p>
<pre><code>UINT8_T *inParam = (UINT8_T *)mxGetPr(ssGetSFcnParam(S, PARAM_IN_PORT_NR)); //;
</code></pre>
<p>but I saw that actually the array elements are stored as 2 bytes. </p>
<pre><code>UINT16_T *inPorts = (UINT16_T *)mxGetPr(ssGetSFcnParam(S, PARAM_IN_PORT_NR)); //
// I can loop through the data
// This is only a snippet
*(inPorts++);
</code></pre>
<p>Why is that? Is this happening in all the Matlab versions?</p>
More answer... (https://stackoverflow.com/questions/59046462/why-char-is-stored-as-2-bytes-in-matlab-s-function)
<pre><code>inParam = char(uint8(1:7))
</code></pre>
<p>In the S-Function I did the followings</p>
<pre><code>UINT8_T *inParam = (UINT8_T *)mxGetPr(ssGetSFcnParam(S, PARAM_IN_PORT_NR)); //;
</code></pre>
<p>but I saw that actually the array elements are stored as 2 bytes. </p>
<pre><code>UINT16_T *inPorts = (UINT16_T *)mxGetPr(ssGetSFcnParam(S, PARAM_IN_PORT_NR)); //
// I can loop through the data
// This is only a snippet
*(inPorts++);
</code></pre>
<p>Why is that? Is this happening in all the Matlab versions?</p>
More answer... (https://stackoverflow.com/questions/59046462/why-char-is-stored-as-2-bytes-in-matlab-s-function)