Convert 1x2 double to 1x1 string
8 次查看(过去 30 天)
显示 更早的评论
I have illustrated my question in the following images.
Data I have - ,
Data I require - ,
How do I convert 1x2 double into 1x1 string?
Thanks in advance
0 个评论
采纳的回答
dpb
2019-6-14
>> string(sprintf('[%d,%d]',s))
ans =
"[3,7]"
>>
or, with features built into the new string class that mimic VB in many ways--
>> "["+s(1)+","+s(2)+"]"
ans =
"[3,7]"
I think the latter is more of a pain to write than the former, but to each his own...
3 个评论
Stephen23
2019-6-15
Simpler:
sprintf("[%d,%d]",s)
% ^ ^ specify the output to be a scalar string.
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Data Type Conversion 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!