How can I join two text string within two cell arrays

1 回表示 (過去 30 日間)
Juan Rosado
Juan Rosado 2012 年 8 月 3 日
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?

採用された回答

Azzi Abdelmalek
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
Walter Roberson 2012 年 8 月 4 日
[s1 s2] would be equivalent.
However, do not forget to put in the space between the strings!
Juan Rosado
Juan Rosado 2012 年 8 月 6 日
Thank you very much.

サインインしてコメントする。

その他の回答 (1 件)

Oleg Komarov
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, '<[^>]+>', '' )

カテゴリ

Help Center および File ExchangeCell Arrays についてさらに検索

タグ

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by