C Structure like variables in MATLAB

5 Ansichten (letzte 30 Tage)
Bharath Lohray
Bharath Lohray am 12 Sep. 2012
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?

Akzeptierte Antwort

Walter Roberson
Walter Roberson am 12 Sep. 2012
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 Kommentar
Walter Roberson
Walter Roberson am 13 Sep. 2012
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).

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (0)

Kategorien

Mehr zu Structures finden Sie in Help Center und File Exchange

Produkte

Community Treasure Hunt

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

Start Hunting!

Translated by