Technical discussion about Matlab and issues related to Digital Signal Processing.
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
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
>
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 >
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
>