what is the meaning of these random numbers
2 次查看(过去 30 天)
显示 更早的评论
- does anyone know the meaning of this ?
- >> r = (randi(0:1, 5, 16)+'0')
- tag_arr =
- 49 48 48 49 48 48 49 48 48 49 49 48 48 49 49 49
- 49 49 49 48 49 48 48 49 48 49 49 48 48 49 49 49
- 48 49 49 48 49 49 48 48 49 48 49 48 49 48 48 48
- 49 48 49 49 49 48 48 48 48 49 48 48 48 48 49 48
- 48 49 49 48 48 49 48 49 49 48 49 48 49 48 49 49
- I am trying to understant why is it giving me only 48 and 49 values?? what is the meaning of this output.?
0 个评论
回答(2 个)
Walter Roberson
2021-8-15
The character code for the character '0' is 48. You are generating random numbers that are either 0 or 1, and you are adding 48, so you are getting 48 or 49. You could have done,
targ_arr = char(randi(0:1, 5, 16)+'0')
to see the character equivalents.
https://en.wikipedia.org/wiki/Basic_Latin_(Unicode_block) U+0030 is '0' . U+ numbers are in hex, so
hex2dec('0030')
0 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Random Number Generation 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!