How to get numbers from char array?
34 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
David Mabwa
am 10 Aug. 2020
Bearbeitet: Adam Danz
am 10 Aug. 2020
I have an array of characters that are produced from a fitSVMposterior
'@(S)sigmoid(S,-1.588276e+00,-2.598747e-01)'
I need to access the numbers in this array but don't know how.
Might anyone know how to do so?
Thanks
0 Kommentare
Akzeptierte Antwort
Adam Danz
am 10 Aug. 2020
Bearbeitet: Adam Danz
am 10 Aug. 2020
Assuming your string is named, str,
str = '@(S)sigmoid(S,-1.588276e+00,-2.598747e-01)';
numstr = regexp(str,'(-)?\d+(\.\d+)?(e(-|+)\d+)?','match')
% numstr =
% 1×2 cell array
% {'-1.588276e+00'} {'-2.598747e-01'}
to convert to double,
num = str2double(numstr)
% num =
% -1.5883 -0.25987
Weitere Antworten (1)
Shae Morgan
am 10 Aug. 2020
Bearbeitet: Shae Morgan
am 10 Aug. 2020
str2double(char_array)
2 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!