how to make string vector?
3 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Mr M.
am 31 Mär. 2015
Bearbeitet: Stephen23
am 31 Mär. 2015
range = [18,29];
how to make ['18','29']?
int2str(range); is not the solution
1 Kommentar
Akzeptierte Antwort
Stephen23
am 31 Mär. 2015
Bearbeitet: Stephen23
am 31 Mär. 2015
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 Kommentare
Weitere Antworten (1)
Jos (10584)
am 31 Mär. 2015
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 Kommentare
Siehe auch
Kategorien
Mehr zu Characters and Strings finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!