C Structure like variables in MATLAB

조회 수: 9 (최근 30일)
Bharath Lohray
Bharath Lohray 2012년 9월 12일
What I want to do is have Q - 10 bit & C - 4 bit and perform the operation -
Q,C = Q,C << 1 (left shift MSB of C into LSB of Q)
Where Q,C is 14 bit treated like a structure in C. This is natively supported in verilog, can be achieved with structures in C. How do I do something similar in MATLAB?

채택된 답변

Walter Roberson
Walter Roberson 2012년 9월 12일
The only option is to use a singe variable that is the concatenation, and to use the bitwise operators to extract bits into Q and C.
  댓글 수: 1
Walter Roberson
Walter Roberson 2012년 9월 13일
Note, by the way, that in C, structures cannot be shifted. C does allow you to create a union of a struct of bitfields, together with an integer, and to shift the integer, and to access the struct fields afterwards. On the other hand, C does not define the order in which multiple bitfields are stored in an integer, only that the bitfields be ordered "from the end" (so if A and B and C are the field names, the order is allowed to be ABC or BCA).

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Structures에 대해 자세히 알아보기

제품

Community Treasure Hunt

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

Start Hunting!

Translated by