Convert 1x2 double to 1x1 string
12 visualizzazioni (ultimi 30 giorni)
Mostra commenti meno recenti
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 Commenti
Risposta accettata
dpb
il 14 Giu 2019
>> 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 Commenti
Stephen23
il 15 Giu 2019
Simpler:
sprintf("[%d,%d]",s)
% ^ ^ specify the output to be a scalar string.
Più risposte (0)
Vedere anche
Categorie
Scopri di più su Characters and Strings in Help Center e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!