Textscan inside a loop
Mostra commenti meno recenti
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
Risposta accettata
Più risposte (0)
Categorie
Scopri di più su Data Import and Export in Centro assistenza e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!