Hi guys, Im coming with background of c/c++/java programming so I've done this function in c++:
uint16_t calc(uint8_t Data, uint16_t Reg)
{
uint8_t i;
unit16_t CRC16_POLY =0x8005;
for (i = 0; i < 8; i++)
{
if (((Reg & 0x8000) >> 8) ^ (Data & 0x80))
{
Reg = (Reg << 1) ^ CRC16_POLY;
}
else
{
Reg = (Reg << 1);
}
Data <<= 1;
}
return Reg;
}
So I want to do the same function but in matlab language, so what I've did is this(still not 100% work and there's a compilation error):
function uint16_t Reg= calc(uint8_t Data, uint16_t Reg)
uint8_t i;
CRC16_POLY =0x8005;
for i = 0:i < 8:i++
{
if ((bitshift((Reg bitwise 0x8000),8) ^ (Data bitwise 0x80))
{ Reg = bitshift(Reg,1) ^ CRC16_POLY;}
else
{Reg = bitshift(Reg,1);}
bitshift(Data,1);
}
return Reg;
end
once I implemented that function in matlab I've a compilation error, could anyone please help me to implement properly that function as what I've done in c++? Yeah Im newbie in matlab and thanks alot for any assistance to implement correctly my function in matlab..
댓글 수: 8
이 댓글에 대한 바로 가기 링크
https://kr.mathworks.com/matlabcentral/answers/577321-function-implementation-matlab-language#comment_965959
이 댓글에 대한 바로 가기 링크
https://kr.mathworks.com/matlabcentral/answers/577321-function-implementation-matlab-language#comment_965959
이 댓글에 대한 바로 가기 링크
https://kr.mathworks.com/matlabcentral/answers/577321-function-implementation-matlab-language#comment_965986
이 댓글에 대한 바로 가기 링크
https://kr.mathworks.com/matlabcentral/answers/577321-function-implementation-matlab-language#comment_965986
이 댓글에 대한 바로 가기 링크
https://kr.mathworks.com/matlabcentral/answers/577321-function-implementation-matlab-language#comment_966025
이 댓글에 대한 바로 가기 링크
https://kr.mathworks.com/matlabcentral/answers/577321-function-implementation-matlab-language#comment_966025
이 댓글에 대한 바로 가기 링크
https://kr.mathworks.com/matlabcentral/answers/577321-function-implementation-matlab-language#comment_966040
이 댓글에 대한 바로 가기 링크
https://kr.mathworks.com/matlabcentral/answers/577321-function-implementation-matlab-language#comment_966040
이 댓글에 대한 바로 가기 링크
https://kr.mathworks.com/matlabcentral/answers/577321-function-implementation-matlab-language#comment_966064
이 댓글에 대한 바로 가기 링크
https://kr.mathworks.com/matlabcentral/answers/577321-function-implementation-matlab-language#comment_966064
이 댓글에 대한 바로 가기 링크
https://kr.mathworks.com/matlabcentral/answers/577321-function-implementation-matlab-language#comment_966067
이 댓글에 대한 바로 가기 링크
https://kr.mathworks.com/matlabcentral/answers/577321-function-implementation-matlab-language#comment_966067
이 댓글에 대한 바로 가기 링크
https://kr.mathworks.com/matlabcentral/answers/577321-function-implementation-matlab-language#comment_967567
이 댓글에 대한 바로 가기 링크
https://kr.mathworks.com/matlabcentral/answers/577321-function-implementation-matlab-language#comment_967567
이 댓글에 대한 바로 가기 링크
https://kr.mathworks.com/matlabcentral/answers/577321-function-implementation-matlab-language#comment_967699
이 댓글에 대한 바로 가기 링크
https://kr.mathworks.com/matlabcentral/answers/577321-function-implementation-matlab-language#comment_967699
댓글을 달려면 로그인하십시오.