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에서 Data Type Conversion에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!