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 !!!
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 Exchange에서 Characters and Strings에 대해 자세히 알아보기

제품

릴리스

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