Textscan inside a loop
Show older comments
Hello,
I am having some difficulties retrieving the info inside some text file i have created, in which there are stock tickers, 3 letters like this :
CCL
EXPE
MAR
so my code is the following :
series = { 'Advertising.lst','AeroDefense.lst','AgriProd.lst'}
for i=1:numel(series)
if selectedItem1 == i
%open file
series{i}
fileid = fopen('series{i}', 'r')
ticker = textscan(fileid,'%s')
fclose =(fileid)
sector = ticker{1}
end
end
The code i think is correctly retrieving the fileid of the series{1} but then when the ticker line is being processed, I get an empty matrix, when the file which is scanned has 3 stock quotes.Normally i should have the sector vector with 3 codes.
Is there an issue in the code.
Thank you very much
Davin
Accepted Answer
More Answers (0)
Categories
Find more on Text Data Preparation in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!