Textscan inside a loop
显示 更早的评论
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
采纳的回答
更多回答(0 个)
类别
在 帮助中心 和 File Exchange 中查找有关 Data Import and Export 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!