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

조회 수: 23(최근 30일)
%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

채택된 답변

Fangjun Jiang
Fangjun Jiang 2011년 11월 13일
put "continue" in a separate line after "catch".
help catch

추가 답변(1개)

Malcolm Lidierth
Malcolm Lidierth 2011년 11월 13일
try
thisdata=urlread(thisurl);
catch
continue
end
....

태그

Community Treasure Hunt

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

Start Hunting!

Translated by