Path: news.mathworks.com!not-for-mail
From: <HIDDEN>
Newsgroups: comp.soft-sys.matlab
Subject: Re: How to parse a string? (Simple question)
Date: Mon, 15 Jun 2009 02:58:03 +0000 (UTC)
Organization: The MathWorks, Inc.
Lines: 15
Message-ID: <h14dbr$ano$1@fred.mathworks.com>
References: <h14aa9$5r9$1@fred.mathworks.com> <h14c86$3if$1@fred.mathworks.com>
Reply-To: <HIDDEN>
NNTP-Posting-Host: webapp-03-blr.mathworks.com
Content-Type: text/plain; charset="ISO-8859-1"
Content-Transfer-Encoding: 8bit
X-Trace: fred.mathworks.com 1245034683 11000 172.30.248.38 (15 Jun 2009 02:58:03 GMT)
X-Complaints-To: news@mathworks.com
NNTP-Posting-Date: Mon, 15 Jun 2009 02:58:03 +0000 (UTC)
X-Newsreader: MATLAB Central Newsreader 1652144
Xref: news.mathworks.com comp.soft-sys.matlab:547410


Thanks Sadik, BUT...

I dumbed down the problem a bit to make it easier to understand. Your solution works for the problem I posted, but in reality, my data is more like this:

data = '*100#*2001#*ExpParameter:T=1.000000;FSC=1.000000;O=1.000000;AR=0.000000;AFD=500.000000;HFD=1500.000000;JD=500.000000;EOX=-0.960000;EOY=-1.470000;EGX=9.000000;EGY=6.000000;FWD=1.750000;#*111#*2111#*ExpParameter:T=2.000000;FSC=2.000000;O=1.000000;AR=0.000000;AFD=500.000000;HFD=1500.000000;JD=500.000000;EOX=-0.960000;EOY=-1.470000;EGX=9.000000;EGY=6.000000;FWD=1.750000;#*122#*2221#';

If you copy and paste it into MATLAB it should automatically create a variable.

As you can see, I have a whole bunch of "markers" and "experimental parameters" in this one long string. Anything between a * and a # that is just a number is a "marker". Anything else, is a parameter. 

Currently, I find the indices for all the *s. Then I check to see if the next character is a number of not. If it is, then it's a marker. Then I parse it out using the index of the next #. I do it in a loop, but I'd like to do it outside of one. Unfortunately, I'm not very familiar with some of the powerful string manipulation functions in MATLAB.

Thanks for your help though. That definitely taught me a new useful function.

Kian