Skip to Main Content Skip to Search
Login
File Exchange
MATLAB Newsgroup
Link Exchange
  Blogs  
 Contest 
MathWorks.com

Thread Subject: text to integer conversion

Subject: text to integer conversion

From: Ralph

Date: 16 Aug, 2007 00:03:42

Message: 1 of 3


I am a beginning MatLab programmer,

I have the string:
“RTop=0 LTop=35 LBot=36 RBot=25 “
I want to convert the 0, 35, 36 & 25 values to independent
integers.

I used the command:
“headCountPos = findstr(textLine,'=');”
to determine the position in the string where each value
starts but don’t know how to extract and convert each value
to an integer. Each value will never exceed 99.

Subject: Re: text to integer conversion

From: us

Date: 16 Aug, 2007 00:14:10

Message: 2 of 3

Ralph:
<SNIP string-to-number evergreen...

> from
> “RTop=0 LTop=35 LBot=36 RBot=25 “
> to
> 0, 35, 36 & 25 values

one of the many solutions

% the data - slightly more complicated...
     s='RTop=0.01 LTop=35.0 LBot=0.36 RBot=25';
% the result
     n=sscanf(s,'%*[^=]=%f').'
% ans = 0.01 35 0.36 25

us

Subject: Re: text to integer conversion

From: S.David S.

Date: 16 Aug, 2007 09:12:49

Message: 3 of 3

"Ralph " <rb@bennett-eng.com> wrote in message
<fa048u$5ls$1@fred.mathworks.com>...
>
> I am a beginning MatLab programmer,
>
> I have the string:
> “RTop=0 LTop=35 LBot=36 RBot=25 “
> I want to convert the 0, 35, 36 & 25 values to independent
> integers.
>
> I used the command:
> “headCountPos = findstr(textLine,'=');”
> to determine the position in the string where each value
> starts but don’t know how to extract and convert each value
> to an integer. Each value will never exceed 99.
>

help with strread.

Tags for this Thread

Everyone's Tags:

Add a New Tag:

Separated by commas
Ex.: root locus, bode

What are tags?

A tag is like a keyword or category label associated with each thread. Tags make it easier for you to find threads of interest.

Anyone can tag a thread. Tags are public and visible to everyone.

Tag Activity for This Thread
Tag Applied By Date/Time
evergreen us 30 Jan, 2008 20:30:29
sscanf us 15 Aug, 2007 20:15:21
conversion us 15 Aug, 2007 20:15:21
number us 15 Aug, 2007 20:15:21
code us 15 Aug, 2007 20:15:21
character us 15 Aug, 2007 20:15:21
numeric us 15 Aug, 2007 20:15:21
rssFeed for this Thread

envelope graphic E-mail this page to a colleague

Public Submission Policy
NOTICE: Any content you submit to MATLAB Central, including personal information, is not subject to the protections which may be afforded information collected under other sections of The MathWorks, Inc. Web site. You are entirely responsible for all content that you upload, post, e-mail, transmit or otherwise make available via MATLAB Central. The MathWorks does not control the content posted by visitors to MATLAB Central and, does not guarantee the accuracy, integrity, or quality of such content. Under no circumstances will The MathWorks be liable in any way for any content not authored by The MathWorks, or any loss or damage of any kind incurred as a result of the use of any content posted, e-mailed, transmitted or otherwise made available via MATLAB Central. Read the complete Disclaimer prior to use.
Related Topics