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

 採用された回答

dpb
dpb 2019 年 6 月 14 日

1 投票

>> 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 件のコメント

Selva Kumar
Selva Kumar 2019 年 6 月 14 日
Thanks a lot !!!
Stephen23
Stephen23 2019 年 6 月 15 日
Simpler:
sprintf("[%d,%d]",s)
% ^ ^ specify the output to be a scalar string.
dpb
dpb 2019 年 6 月 15 日
編集済み: dpb 2019 年 6 月 15 日
Good catch, Stephen...let the interpreter do the cast...

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

ヘルプ センター および File ExchangeData Type Conversion についてさらに検索

製品

リリース

R2019a

質問済み:

2019 年 6 月 14 日

編集済み:

dpb
2019 年 6 月 15 日

Community Treasure Hunt

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

Start Hunting!

Translated by