ASCII conversion (MATLAB)

hi,
i'm writing a program in MATLAB that captures data from the different sensors of an external instrument through the serial port of  p.c and then scans the data and then records and displays it. but  i'm facing a problem now  that  is the data being captured from the device is in ASCII format, for which i needed help,  to convert this data in  numerical format so that i could substitute the values acquired into mathematical equations for more future processing and also plot them in graphs.
the format of the ASCII data i'm capturing is-{ -4.319005,20.165850,-0.857791,-0.923775,-31.366320}

can anyone help me with this.
PinpointsystemsAsked:
Who is Participating?
 
DefreeComanConnect With a Mentor Commented:
Check out http://www.mathworks.com/products/matlab/functionlist.html
Look particularly at strtok and str2double (or str2num)
You should be able to do something like this:

remains = strtok(data, '{}');
count = 0;
while true
    count = count + 1;
    [nextVal, remains] = strtok(remains, ',');
    if isempty(nextVal) break; end
    values(count) = str2double(nextVal);
end
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.