Bit shift operation on 2d array problem

1 次查看(过去 30 天)
GLW
GLW 2013-5-30
I'm writing some behavioral code for testing an embedded matlab block that ouputs serial data. I want to capture the serial data using a 2d array structure being 120 elements deep by 24 bits wide. The incoming serial data is shifted to the left, then when 24 bits have been captured the next element is filled and so on.
this is the command that I use to perform the shift:
Arr(IndexCnt)(24:2) = horzcat(Arr(IndexCnt)(23:2),serdat)
The error I get is:
"Parse error: ()-indexing must appear last in an index expression."
Any idea where I'm going wrong?
Many thanks

回答(1 个)

Walter Roberson
Walter Roberson 2013-5-30
24:2 would be the empty list, as would be 23:2 . Perhaps you want 24:-1:2 and 23:-1:2 ?
MATLAB does not permit indexing by bits. MATLAB uses bitget() and bitset(). bitset() is unfortunately not designed to be able to set multiple bits simultaneously for arrays.

类别

Help CenterFile Exchange 中查找有关 Logical 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by