how to make string vector?
조회 수: 4 (최근 30일)
이전 댓글 표시
range = [18,29];
how to make ['18','29']?
int2str(range); is not the solution
댓글 수: 1
채택된 답변
Stephen23
2015년 3월 31일
편집: Stephen23
2015년 3월 31일
Here are three possible interpretation of the question.
1. To create one single string, exactly as per the original question:
>> vec = [18,29];
>> sprintf('%d',vec)
ans =
'1829'
2. To create a cell array of strings:
>> arrayfun(@int2str,vec,'UniformOutput',false)
ans =
'18' '29'
3. To create a character array with spaces separating the values:
>> int2str(vec) % or num2str
ans = '18 29'
댓글 수: 0
추가 답변 (1개)
Jos (10584)
2015년 3월 31일
You realise that, in ML, ['18','29'] is exactly the same as the single character array '1829' ?
a = [18, 29]
str = sprintf('%d',a)
댓글 수: 0
참고 항목
카테고리
Help Center 및 File Exchange에서 Characters and Strings에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!