필터 지우기
필터 지우기

can we use bitwise operators in matlab?

조회 수: 4 (최근 30일)
Imtiaz nabi
Imtiaz nabi 2022년 2월 27일
답변: Walter Roberson 2022년 2월 27일
Hi there, I want to implement a C code in matlab in which there is a bitwise operator that is shifing bit to the right. My uestion is can we implement something in matlab please? if yes then what would be the exact match for the following lines of code?
chan->iword = ims/600; // 1 word = 30 bits = 600 ms
ims -= chan->iword*600;
chan->ibit = ims/20; // 1 bit = 20 code = 20 ms
ims -= chan->ibit*20;
chan->icode = ims; // 1 code = 1 ms
chan->codeCA = chan->ca[(int)chan->code_phase]*2-1;
chan->dataBit = (int)((chan->dwrd[chan->iword]>>(29-chan->ibit)) & 0x1UL)*2-1;

채택된 답변

Walter Roberson
Walter Roberson 2022년 2월 27일
Be careful that in some cases C does not define whether the shift is a logical shift or an arithmetic shift.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Workspace Variables and MAT-Files에 대해 자세히 알아보기

제품


릴리스

R2017b

Community Treasure Hunt

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

Start Hunting!

Translated by