MATLAB Answers

How do I convert an integer into a binary vector?

조회 수: 96(최근 30일)
Justin Mellor
Justin Mellor 8 Aug 2014
댓글: dpb 11 Aug 2014
I would like to use the General CRC Generator to calculate a CRC based on 32 bit integer value that is going to be transmitted as serial (ARINC 429 data) using Simulink Real-Time. My 32 bit integer is computed every frame based on a number of dynamic input values. The problem is that the CRC block requires a binary column vector as its input and so I need to create this from my 32 bit integer value. Is there a block that does this? Surely I don't need to pick off each bit individually to create a vector??
Justin

  댓글 수: 0

로그인 to comment.

답변(2개)

dpb
dpb 8 Aug 2014
v=dec2bin(intval)-'0';

  댓글 수: 0

로그인 to comment.


Justin Mellor
Justin Mellor 11 Aug 2014
Thanks - I am doing this with a Simulink model - I have tried putting this in a MATLAB function block, but get the following error:
Data 'y' (#38) is inferred as a variable size matrix, while its specified type is something else.
Is there an example that you can point me to that shows the General CRC generator block being used in a Simulink model where the input is a dynamically changing value (the example just shows an input vector defined as a constant).
Regards
Justin

  댓글 수: 1

dpb
dpb 11 Aug 2014
I've never seen a Simulink installation even, sorry...

로그인 to comment.

이 질문에 답변하려면 로그인을(를) 수행하십시오.


Translated by