ASCII conversion (MATLAB)

Posted on 2007-07-24
Last Modified: 2016-02-10
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.
Question by:Pinpointsystems
    1 Comment
    LVL 3

    Accepted Solution

    Check out
    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);

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    Highfive + Dolby Voice = No More Audio Complaints!

    Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

    If you haven’t already, I encourage you to read the first article ( in my series to gain a basic foundation of R and R Studio.  You will also find the …
    Go is an acronym of golang, is a programming language developed Google in 2007. Go is a new language that is mostly in the C family, with significant input from Pascal/Modula/Oberon family. Hence Go arisen as low-level language with fast compilation…
    The goal of this video is to provide viewers with basic examples to understand and use switch statements in the C programming language.
    The viewer will learn additional member functions of the vector class. Specifically, the capacity and swap member functions will be introduced.

    760 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    12 Experts available now in Live!

    Get 1:1 Help Now