# Finding specific phrases within a cell array (1)

1 view (last 30 days)
Juan Rosado on 16 Jul 2012
Greetings,
I am working with a total of nine(9) text strings within nine(9) cell ( {9x1} )
and I am trying to take specific sentences of the text strings.
For example, one text string says:
EAST WINDS 15 TO 20 KNOTS. SEAS 4 TO 6 FEET.
I am trying to divide these two sentences in two structured variables under the name Today.
Today.Winds = EAST WINDS 15 TO 20 KNOTS
Today.Waves = SEAS 4 TO 6 FEET
The 9 different strings represents the 7 days of the week, plus today and night forecast, resulting in 9 different strings
The other strings outputs would go like this:
Tonight.Winds = EAST NORTHEAST WINDS 10 TO 14 KNOTS
Tonight.Waves = SEAS 3 TO 5 FEET
Monday.Winds = EAST WINDS 14 TO 19 KNOTS
Monday.Waves = SEAS 4 TO 6 FEET
I was thinking of telling MATLAB to break when he reaches the first dot and imprint the string as Today.wind, then continue till the next dot, break and imprint it as Today.waves.
How can I do this?
##### 2 CommentsShowHide 1 older comment
Juan Rosado on 17 Jul 2012
My apologies. It won't happen again.

C.J. Harris on 16 Jul 2012
See 'strtok' as one possible solutions. For example:
celltxt{1} = 'EAST WINDS 15 TO 20 KNOTS. SEAS 4 TO 6 FEET.';
[tok, rem] = strtok(celltxt{1}, '.');
Tonight.Winds = tok;
Tonight.Waves = rem(3:end-1); % removing first two and last character
Juan Rosado on 18 Jul 2012
Indeed Harris I am using cell array and sorry for the flag.