double2str and bin2str
42 次查看(过去 30 天)
显示 更早的评论
Is there any valid commands in matlab like double2str and bin2str for data type conversion and storage?
0 个评论
回答(2 个)
Awais Saeed
2021-11-14
Doing
help bin2str
% and
help double2str
did not show any results from which I assume there are no such functions. Use num2str() or sprintf instead
binary = randi([0 1],1,10);
binaryStr = sprintf('%d', binary)
binaryStr2 = num2str(binary)
class(binaryStr)
class(binaryStr2)
1 个评论
Awais Saeed
2021-11-14
if you strickly want a string then
binary = randi([0 1],1,10);
Str = sprintf("The binary string is: %s", num2str(binary))
class(Str)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Dates and Time 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!