How do I skip a text string within a cell array
1 view (last 30 days)
Show older comments
I have a text file input that I divided in a {43 x 1} cell array, and the sentences are strings. I would like to skip some information from the text file.
The text file cells are these:
'REST OF TODAY'
'TROPICAL STORM CONDITIONS POSSIBLE. EAST NORTHEAST'
'WINDS 28 TO 33 KNOTS. SEAS 8 TO 12 FEET. INTERMITTENT SHOWERS AND'
'SCATTERED THUNDERSTORMS. '
and I am proceding the following way:
row = find(strncmpi(outcell, 'REST', 4));
str1 = outcell(row(1)+1);
str2 = outcell(row(1)+2);
S1 = regexprep(str1{1}, 'TO', ' : ');
S2 = regexprep(str2{1}, 'TO', ' : ');
unite = [S1 S2];
[win, wav] = strtok(unite, '.');
wavchar=char(wav);
winchar=char(win);
REST_OF_TODAY.Winds = winchar;
REST_OF_TODAY.Waves = strtok(wavchar(3:end), '.');
REST_OF_TODAY
The output is this:
REST_OF_TODAY =
Winds: 'TROPICAL S : RM CONDITIONS POSSIBLE'
Waves: 'EAST NORTHEASTWINDS 28 : 33 KNOTS'
and I want it to be like this:
REST_OF_TODAY =
Winds: 'EAST NORTHEASTWINDS 28 : 33 KNOTS'
Waves: 'SEAS 8 TO 12 FEET'
In other words, skip the sentence 'TROPICAL STORM CONDITIONS POSSIBLE' and start with
EAST NORTHEAST'
'WINDS 28 TO 33 KNOTS
Can you please help?
0 Comments
Answers (0)
See Also
Categories
Find more on Dates and Time in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!