Any ideas why I am getting this 'catch' error? Does anyone know how I can solve it?

7 views (last 30 days)
%Code to Get Matrix
fid=fopen('C:\Users\Laurentiu Galan\Desktop\Tickers.csv');
C = textscan(fid, '%s');
fclose(fid);
%Grab First Value (Just as check)
thisval=(C{1});
% Calculate Number of Tickers
D=size(thisval);
NumTick=D(1,1);
%Calculate Loop to download tickers
for i=1:NumTick
thissym=thisval{i};
thisurl = strcat('http://ichart.finance.yahoo.com/table.csv?s=', thissym, '&d=10&e=8&f=2011&g=d&a=0&b=1&c=2000&ignore=.csv');
thisdata=urlread(thisurl);
catch continue;
end
thisfilename = strcat(thissym, '.csv');
outputfile = strcat('C:\Users\Laurentiu Galan\Desktop\tickoutput\',thisfilename);
thisfileid=fopen(outputfile, 'wt')
fprintf(thisfileid, '%s\n',thisdata)
fclose(thisfileid)
end
I am getting an error right after the catch, saying illegal use of the word. Any ideas how I can solve this? I know the rest of the code works. Basically, I am trying to get the code to download the tickers from yahoo finance and to skip the ticker if there is a url read error.
Thanks

Accepted Answer

Fangjun Jiang
Fangjun Jiang on 13 Nov 2011
put "continue" in a separate line after "catch".
help catch

More Answers (1)

Malcolm Lidierth
Malcolm Lidierth on 13 Nov 2011
try
thisdata=urlread(thisurl);
catch
continue
end
....

Categories

Find more on Cell Arrays in Help Center and File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!