フィルターのクリア

How to change data and display a text using cell arrays.

2 ビュー (過去 30 日間)
Juan Rosado
Juan Rosado 2012 年 7 月 1 日
Greetings,
The program I'm developing takes the html code from an internet forecasting page, ignores all the html tags and stores the text on MATLAB as a cell array.
The problem is I can't get to replace some quotation marks I keep getting in the Output.
The program goes like this:
clc,clear;
urlwrite('http://weather.noaa.gov/cgi-bin/fmtbltn.pl?file=forecasts/marine/coastal/am/amz722.txt','Anegada_Passage_Southward.txt');
fid=fopen('Anegada_Passage_Southward.txt');
y=fgetl(fid);
data = textscan( fid, '%s', 'Delimiter', ''); %read the entire file as strings, one per line.
out = regexprep( data{1}, '<[^>]+>', '' ); %remove the HTML
for i=1:1:36
if out{i}=='';
setfield(out,{i},'');
else
getfield(out,{i});
end
end
fclose(fid);
On the 'if' part I keep geeting this Error:
Error using ==> eq Matrix dimensions must agree.
Error in ==> pru at 12 if out{i}=='';
I want to repace those '' with empty lines to divide paragraphs.
What can I do?
  1 件のコメント
per isakson
per isakson 2012 年 7 月 1 日
Move "fclose(fid);" to directly after textscan. You don't want to keep the file open longer than necessary, since it may cause problems during debugging.

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

採用された回答

per isakson
per isakson 2012 年 7 月 1 日
The variable, out, is a cell array of strings. The functions, setfield and getfield, operate on structure arrays.
Replace the for-loop by
for ii = 1:1:36
if isempty( out{ii} )
out{ii} = []; % or do nothing
else
disp( out{ii} )
end
end

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeLarge Files and Big Data についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by