Sign in

username:

password:



Not a member?

Search matlab



Search tips

Subscribe to matlab



matlab by Keywords

Atanh | Autocorrelation | Bandpass Filter | C++ | Conv | Database | Deconv | Excel | FFT | Filter | Filtering | FIR | Fourier Transfrom | FSK | Gaussian Noise | Haykin | IFFT | Image | Java | LFSR | LMS | LPC | MEX | OFDM | QPSK | Radix | Random | Sampling | Segmentation | Simulink | Visual Basic | Waveform | Wavelet

Ads

Discussion Groups

Discussion Groups | Matlab DSP | Converting strings to numbers

Technical discussion about Matlab and issues related to Digital Signal Processing.

  

Post a new Thread

Converting strings to numbers - teh_gamr - Apr 28 21:48:54 2008



Hi all,

I've got a microcontroller reading values from two sensors and sending
serially to MATLAB. It sends the first value, new line (ASCII 13, or
whatever I decide), then the second value, new line, etc.

If there's only one value i have no problem assigning that to a
variable. But my problem is in splitting the string at the new line.
Is it possible?

Thanks,
Ash


(You need to be a member of matlab -- send a blank email to matlab-subscribe@yahoogroups.com )

Re: Converting strings to numbers - "Raja' S. Alomari" - Apr 29 7:14:09 2008

Hi,
You can just make a small .m file to read in the input string and returns
back the values by searching the string for the "new line character" you
decided to using one of the string search functions such as strfind:

example:
S = 'Find the starting indices of the pattern string';
strfind(S, 'in')
ans =
     2    15    19    45

More info:
http://www.mathworks.com/access/helpdesk/help/techdoc/index.html?/access/helpdesk/help/techdoc/
ref/strfind.html&http://www.google.com/search?source=ig&hl=en&rlz=&q=strfind

Hope that helps,
Best regards,
Raja'

On Mon, Apr 28, 2008 at 4:57 PM, teh_gamr <a...@gmail.com> wrote:

>   Hi all,
>
> I've got a microcontroller reading values from two sensors and sending
> serially to MATLAB. It sends the first value, new line (ASCII 13, or
> whatever I decide), then the second value, new line, etc.
>
> If there's only one value i have no problem assigning that to a
> variable. But my problem is in splitting the string at the new line.
> Is it possible?
>
> Thanks,
> Ash
>



(You need to be a member of matlab -- send a blank email to matlab-subscribe@yahoogroups.com )

Re: Converting strings to numbers - Nadimul Haque FAISAL - Apr 29 7:14:31 2008

Hi Ashraf
Did you mean? E.g.

y1=y(:,1); % channel 1 column of data
y2=y(:,2); % channel 2 column of data
ys=y2(10:end); % splitting data points from 10 to the end for vector y2

regards
Faisal

2008/4/28 teh_gamr <a...@gmail.com>:

>   Hi all,
>
> I've got a microcontroller reading values from two sensors and sending
> serially to MATLAB. It sends the first value, new line (ASCII 13, or
> whatever I decide), then the second value, new line, etc.
>
> If there's only one value i have no problem assigning that to a
> variable. But my problem is in splitting the string at the new line.
> Is it possible?
>
> Thanks,
> Ash
>



(You need to be a member of matlab -- send a blank email to matlab-subscribe@yahoogroups.com )

Re: Converting strings to numbers - Raja' Alomari - Apr 30 8:19:52 2008

Hi,
You can just make a small .m file to read in the input string and 
returns back the values by searching the string for the "new line 
character" you decided to using one of the string search functions such 
as strfind:
 
example:
S = 'Find the starting indices of the pattern string';
strfind(S, 'in')
ans =
     2    15    19    45
 
More info: 
http://www.mathworks.com/access/helpdesk/help/techdoc/index.html?/access
/helpdesk/help/techdoc/ref/strfind.html&http://www.google.com/search?
source=ig&hl=en&rlz=&q=strfind
 
Hope that helps,
Best regards,
Raja'

--- In m...@yahoogroups.com, "teh_gamr" <ashraf.hammoud@...> wrote:
>
> Hi all,
> 
> I've got a microcontroller reading values from two sensors and sending
> serially to MATLAB. It sends the first value, new line (ASCII 13, or
> whatever I decide), then the second value, new line, etc.
> 
> If there's only one value i have no problem assigning that to a
> variable. But my problem is in splitting the string at the new line.
> Is it possible?
> 
> Thanks,
> Ash
>



(You need to be a member of matlab -- send a blank email to matlab-subscribe@yahoogroups.com )