フィルターのクリア

Can I use hexa address like '0xF2' value in Matlab?

2 ビュー (過去 30 日間)
Haksun Lee
Haksun Lee 2012 年 7 月 12 日
Hi guys all...
I am programming about serial communication..
I wandering if I can use hexa address like '0xF2' value such as c code.
For example, refer to following.
ch=Temp_buffer(1);
if(ch=0xF2)
data[0]=ch;
elseif(ch=0xF6)
data[1]=ch;
end
Like above, can I use hexa address like '0xF2' value in Matlab?
Also how can I get bit stream data through serial communication.
Thanks~

回答 (3 件)

Jan
Jan 2012 年 7 月 12 日
sscanf('F2', '%x') is much faster than hex2dec.

Mike Hosea
Mike Hosea 2012 年 7 月 12 日
Don't know anything about the second question. As to the first, because MATLAB does not have a hex format in the language, you have to use strings and hex2dec. For example,
if ch == hex2dec('F2')
data(1) = ch;
elseif ch == hex2dec('F6')
data(2) = ch;
end
Obviously it would be a little more efficient in MATLAB just to use the decimal values and put the hex values in a comment.
if ch == 242 % 0xF2
data(1) = ch;
elseif ch == 246 % 0xF6
data(2) = ch;
end

Haksun Lee
Haksun Lee 2012 年 7 月 13 日
Thank you for letting me know...
Have a nice day!!

カテゴリ

Help Center および File ExchangeDigital Input and Output についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by