Greetings,
I am developing a program on MATLAB that takes a forecast data from a web page, ignores de html tags and imprints it on MATLAB memory as a cell array.
The program goes like this:
urlwrite('http://weather.noaa.gov/cgi-bin/fmtbltn.pl?file=forecasts/marine/coastal/am/amz725.txt','Water_Coastal_Southern_Puerto_Rico_Out.txt'); % URL from forecast web page
fid=fopen('Water_Coastal_Southern_Puerto_Rico_Out.txt');y=fgetl(fid);data = textscan( fid, '%s', 'Delimiter', ''); %read the entire file as strings, one per line.
fclose(fid);out = regexprep( data{1}, '<[^>]+>', '' ) %remove the HTML
n=length(out);for ii = 1:1:n if isempty ( out{ii} ); % ignores the empty lines
out{ii} = []; else end end
If you run the program you will see the cell array.
I am trying to tell MATLAB to give the user specific lines teling the prediction of a certaing time of day.
For instance, if I write 'U' in the Command Window, refering to Tuesday, MATLAB should tell the user:
TUESDAY EAST WINDS 13 TO 17 KNOTS. SEAS 3 TO 5 FEET. ISOLATED THUNDERSTORMS.
So far I have develop this code for input output commands,
time=input('Input your forecast interest( (R)REST OF TODAY / (T)TONIGHT / (U)TUESDAY / (UN)TUESDAY NIGHT / (W)WEDNESDAY / (TH)THURSDAY / (F)FRIDAY )\n: ','s');for ii=1:1:n if isappdata ( 'R', ); % isappdata (h,name); I dont know what to put on %the name part of isappdata.
disp(out{12}); % html lines
disp(out{13}); disp(out{14}); end end
But since its a forecast page the html lines change daily.
I need a command to tell MATLAB to extract the desired forecast from the URL and display it to the user, keeping in mind that the page upgrades daily. My boss keeps suggesting me to use the eval command, but I am trying my hard to not use it.
What do you suggest me to do?
Thank you for your time,
JJR
Best Answer