How do I skip a text string within a cell array
1 次查看(过去 30 天)
显示 更早的评论
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 个评论
回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Dates and Time 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!