Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

Thread Subject:
find string or charachter in Matrix or Array

Subject: find string or charachter in Matrix or Array

From: edward kabanyas

Date: 20 Jul, 2011 07:33:09

Message: 1 of 3

Hi friends,

I want to take several values in the following type of array. The structure is not uniform.

List of the players and their score
PlayerW number of them 1 score: 1
PlayerB number of them 1 score: 2
PlayerB number of them 2 score: 3
PlayerB number of them 4 score: 4
PlayerB number of them 5 score: 5
List of the teams and their score
Team1 number of them 1 score: 1
Team2 number of them 1 score: 2
Team3 number of them 1 score: 3
Team4 number of them 1 score: 4
Team5 number of them 1 score: 5

For example, I want to take the value of PlayerB and only the number and the score, so that the output is:

1 2
2 3
4 4
5 5

I try to use findstr, however it did not work for several columns' case. Do you have any solution ?

Thanks friends

Edward

Subject: find string or charachter in Matrix or Array

From: kinor

Date: 20 Jul, 2011 13:01:10

Message: 2 of 3

"edward kabanyas" <djuky_hmi@yahoo.com> wrote in message <j060bl$ne5$1@newscl01ah.mathworks.com>...
> Hi friends,
>
> I want to take several values in the following type of array. The structure is not uniform.
>
> List of the players and their score
> PlayerW number of them 1 score: 1
> PlayerB number of them 1 score: 2
> PlayerB number of them 2 score: 3
> PlayerB number of them 4 score: 4
> PlayerB number of them 5 score: 5
> List of the teams and their score
> Team1 number of them 1 score: 1
> Team2 number of them 1 score: 2
> Team3 number of them 1 score: 3
> Team4 number of them 1 score: 4
> Team5 number of them 1 score: 5
>
> For example, I want to take the value of PlayerB and only the number and the score, so that the output is:
>
> 1 2
> 2 3
> 4 4
> 5 5
>
> I try to use findstr, however it did not work for several columns' case. Do you have any solution ?
>
> Thanks friends
>
> Edward

 

Hi,

i assume you have a cellarray ? try strfind, it gives you a cellarray which indicates you where PlayerB
then you could convert the lines in which PlayerB occurs into uint8 and look for values contained in uint8('0123456789')
hopefully someone gives you a faster solution

hth
kinor

Subject: find string or charachter in Matrix or Array

From: edward kabanyas

Date: 21 Jul, 2011 06:24:07

Message: 3 of 3

Kinor, thanks for the suggestion. Finally I can read the data using ismember through several steps.

Edward


"kinor" wrote in message <j06jim$cl6$1@newscl01ah.mathworks.com>...
> "edward kabanyas" <djuky_hmi@yahoo.com> wrote in message <j060bl$ne5$1@newscl01ah.mathworks.com>...
> > Hi friends,
> >
> > I want to take several values in the following type of array. The structure is not uniform.
> >
> > List of the players and their score
> > PlayerW number of them 1 score: 1
> > PlayerB number of them 1 score: 2
> > PlayerB number of them 2 score: 3
> > PlayerB number of them 4 score: 4
> > PlayerB number of them 5 score: 5
> > List of the teams and their score
> > Team1 number of them 1 score: 1
> > Team2 number of them 1 score: 2
> > Team3 number of them 1 score: 3
> > Team4 number of them 1 score: 4
> > Team5 number of them 1 score: 5
> >
> > For example, I want to take the value of PlayerB and only the number and the score, so that the output is:
> >
> > 1 2
> > 2 3
> > 4 4
> > 5 5
> >
> > I try to use findstr, however it did not work for several columns' case. Do you have any solution ?
> >
> > Thanks friends
> >
> > Edward
>
>
>
> Hi,
>
> i assume you have a cellarray ? try strfind, it gives you a cellarray which indicates you where PlayerB
> then you could convert the lines in which PlayerB occurs into uint8 and look for values contained in uint8('0123456789')
> hopefully someone gives you a faster solution
>
> hth
> kinor

Tags for this Thread

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.

Contact us