[Last Call] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

ASCII conversion (MATLAB)

Posted on 2007-07-24
1
Medium Priority
?
9,505 Views
Last Modified: 2016-02-10
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.
0
Comment
Question by:Pinpointsystems
1 Comment
 
LVL 3

Accepted Solution

by:
DefreeComan earned 1500 total points
ID: 19562338
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

Featured Post

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

There is an easy way, in .NET, to centralize the treatment of all unexpected errors. First of all, instead of launching the application directly in a Form, you need first to write a Sub called Main, in a module. Then, set the Startup Object to th…
When we want to run, execute or repeat a statement multiple times, a loop is necessary. This article covers the two types of loops in Python: the while loop and the for loop.
This tutorial covers a step-by-step guide to install VisualVM launcher in eclipse.
This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.
Suggested Courses
Course of the Month18 days, 2 hours left to enroll

830 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