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

 Réponse acceptée

dpb
dpb le 14 Juin 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 commentaires

Selva Kumar
Selva Kumar le 14 Juin 2019
Thanks a lot !!!
Simpler:
sprintf("[%d,%d]",s)
% ^ ^ specify the output to be a scalar string.
dpb
dpb le 15 Juin 2019
Modifié(e) : dpb le 15 Juin 2019
Good catch, Stephen...let the interpreter do the cast...

Connectez-vous pour commenter.

Plus de réponses (0)

Catégories

En savoir plus sur Characters and Strings dans Centre d'aide et File Exchange

Produits

Version

R2019a

Community Treasure Hunt

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

Start Hunting!

Translated by