How to change ASCII code into decimal using simulink block
Ältere Kommentare anzeigen
The data I get from serial port are in form of ASCII And I want to get a decimal form. Please show me an example using Simulink block to change ASCII into decimal. Thanks a lot. ^_^
3 Kommentare
Walter Roberson
am 25 Jan. 2016
Which block are you using to receive the data? The ones I find only deal with bytes in numeric form, which goes along with the fact that native Simulink signals cannot be character type.
Sibei Liang
am 25 Jan. 2016
Sibei Liang
am 25 Jan. 2016
Antworten (1)
Walter Roberson
am 25 Jan. 2016
In the (unusual) case where the input is a stream of ASCII digits that are all independent from each other, then
input_byte - '0'
converts the ASCII to the corresponding decimal digit.
Or since you are doing it in Simulink, subtract 48.
I say this is unusual because typically when values are encoded as ASCII digits, multiple digits are used to transfer decimal values, either fixed width or space delimited or comma delimited or CR or NL or CR/NL delimited.
1 Kommentar
Sibei Liang
am 25 Jan. 2016
Kategorien
Mehr zu Simulink finden Sie in Hilfe-Center und File Exchange
Produkte
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!