Bit shift operation on 2d array problem
2 views (last 30 days)
Show older comments
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
0 Comments
Answers (1)
Walter Roberson
on 30 May 2013
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.
0 Comments
See Also
Categories
Find more on Construct and Work with Object Arrays in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!