How to make this string a = '(0 0 0)' into a double b = [0 0 0]?
3 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Wictor Oliveira
am 5 Aug. 2022
Kommentiert: Walter Roberson
am 5 Aug. 2022
Suppose I don't know what are the number inside the a string, it could be:
a = '(12 2.8 1.22)' % each number is separated by a single space
which should then be:
b = [12 2.8 1.22]
0 Kommentare
Akzeptierte Antwort
Kevin Holly
am 5 Aug. 2022
a = '(12 2.8 1.22)'
a = strrep(a,')',']');
a = strrep(a,'(','[');
b = str2num(a)
Weitere Antworten (1)
Fangjun Jiang
am 5 Aug. 2022
Bearbeitet: Fangjun Jiang
am 5 Aug. 2022
a = '(12 2.8 1.22)';
b=sscanf(a,'(%f %f %f)')
b=transpose(sscanf(a,'(%f %f %f)'))
2 Kommentare
Siehe auch
Kategorien
Mehr zu String 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!