MATLAB爱好者论坛-LabFans.com

MATLAB爱好者论坛-LabFans.com (https://www.labfans.com/bbs/index.php)
-   资料存档 (https://www.labfans.com/bbs/forumdisplay.php?f=72)
-   -   Why char is stored as 2 bytes in Matlab S-Function (https://www.labfans.com/bbs/showthread.php?t=22155)

poster 2019-11-26 16:43

Why char is stored as 2 bytes in Matlab S-Function
 
<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>



[url=https://stackoverflow.com/questions/59046462/why-char-is-stored-as-2-bytes-in-matlab-s-function]More answer...[/url]


所有时间均为北京时间。现在的时间是 21:40

Powered by vBulletin
版权所有 ©2000 - 2025,Jelsoft Enterprises Ltd.