Why is str2num returning [] and str2double returning NaN?
Mostrar comentarios más antiguos
I am new to Matlab and am having a hard ime figuring out how to turn a string into a number.
I have a line of text data that shows up as a cell, and I was able to convert that into a string. Then I created a new by extracting a specific part of the previous string. The specific part of the original string that I extracted is a single number. I want to turn it into a number so that I am able to use it to do a conversion.
This is what I have in my script:
v = A.textdata(5,:)
str = char(v)
newStr1 = extractBetween(char(v),'Accel sens, ',',counts/g')
newStr2 = extractBetween(char(v),'Mag sens, ',',counts/mT')
X = str2double('newStr1')
Y = str2doule('newStr2')
This is what is returned when I test the code:
(Y is cut off but it returned NaN)

Respuesta aceptada
Más respuestas (0)
Categorías
Más información sobre Data Type Conversion en Centro de ayuda y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!