MATLAB: Is str2num returning [] and str2double returning NaN

str2num str2double nan

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)

Best Answer

X = str2double('newStr1')
Y = str2doule('newStr2')
You're trying to turn the literal character arrays 'newStr1' and 'newStr2' into numbers which, while they have an embedded numeric character aren't recognizable as numbers.
You intended to use the variables instead--
X = str2double(newStr1)
Y = str2doule(newStr2)