How can I join two text string within two cell arrays
조회 수: 1 (최근 30일)
이전 댓글 표시
I have a text file input that I divided in a {34 x 1} cell array, and the sentences are strings. I would like to join some of the cells.
I am proceding in the following way:
urlwrite('http://weather.noaa.gov/cgi-bin/fmtbltn.pl?file=forecasts/marine/coastal/am/amz745.txt','Coastal_Waters_Southwestern.txt');
fid=fopen('Coastal_Waters_Southwestern.txt');
data = textscan(fid, '%s', 'Delimiter','');
fclose(fid);
out = regexprep( data{1}, '<[^>]+>', '' );
outcell = cell(out);
Two lines ( outcell {23,1} & outcell {24,1} ) are stored in MATLAB memory like this:
'EAST SOUTHEAST WINDS 20 TO 25 KNOTS. SEAS 6 TO'
'8 FEET. SCATTERED SHOWERS. '
And I want them this way:
'EAST SOUTHEAST WINDS 20 TO 25 KNOTS. SEAS 6 TO 8 FEET. SCATTERED SHOWERS. '
Can you please help?
댓글 수: 0
채택된 답변
Azzi Abdelmalek
2012년 8월 3일
s1='EAST SOUTHEAST WINDS 20 TO 25 KNOTS. SEAS 6 TO'
s2= '8 FEET. SCATTERED SHOWERS. '
s=strcat(s1,s2)
댓글 수: 2
Walter Roberson
2012년 8월 4일
[s1 s2] would be equivalent.
However, do not forget to put in the space between the strings!
추가 답변 (1개)
Oleg Komarov
2012년 8월 3일
편집: Oleg Komarov
2012년 8월 3일
What about this alternative approach:
data = urlread('http://weather.noaa.gov/cgi-bin/fmtbltn.pl?file=forecasts/marine/coastal/am/amz745.txt');
out = regexprep(data, '<[^>]+>', '' )
댓글 수: 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!