Different size definition in Matlab and Simulink

2 vues (au cours des 30 derniers jours)
Leon
Leon le 16 Déc 2022
Commenté : Leon le 18 Déc 2022
I am trying to work with TCP/IP communication in Simulink using "Simulink Coder" and "Simulink Desktop Real-Time" and faced a confusing problem. The size of an expression in Matlab is [1, 1].
>> bytes = uint8([0, 1]);
>> byte = typecast(bytes, 'uint16');
>> size(typecast(bytes, 'uint16'))
ans =
1 1
>>
However, when the same exact expression is run in Simulink through the "Matlab Function" block, the result size is [8, 1], but it is needed to be [1, 1].
How could it be solved or explained?

Réponses (1)

VBBV
VBBV le 16 Déc 2022
Modifié(e) : VBBV le 16 Déc 2022
It seems you are accessing 2 elements of array data with each representing 4 byte register address. Each element of which has 4 digits. For example, a 32 Bit x86 chip has register length of 4 byte can be stored and accessed as you did
  1 commentaire
Leon
Leon le 18 Déc 2022
Do you have any ideas how to solve it?

Connectez-vous pour commenter.

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by