When I run the following code it only shows the last file in the directory in MATLAB workspace? How do I get all the files in my directory saved in the workspace?
2 visualizzazioni (ultimi 30 giorni)
Mostra commenti meno recenti
Anuradha Bhattacharya
il 22 Set 2016
Commentato: Anuradha Bhattacharya
il 22 Set 2016
ivsFiles = dir('*.ivs');
numfiles = length(ivsFiles);
for k = 1:103;
filename = ivsFiles(k).name;
fileID = filename;
C = textscan(filename,'%d');
end
3 Commenti
Risposta accettata
KSSV
il 22 Set 2016
Modificato: KSSV
il 22 Set 2016
ivsFiles = dir('*.ivs');
numfiles = length(ivsFiles);
C = cell(numfiles,1) ; % initialize each file's data into a cell
for k = 1:numfiles;
filename = ivsFiles(k).name;
fileID = filename;
C{i} = textscan(filename,'%d');
end
Please note that, you will eat up the memory if the files are huge.
2 Commenti
Walter Roberson
il 22 Set 2016
ivsFiles = dir('*.ivs');
numfiles = length(ivsFiles);
C = cell(numfiles,1) ; % initialize each file's data into a cell
for k = 1:numfiles;
filename = ivsFiles(k).name;
fileID = fopen(filename, 'rt');
C{i} = textscan(fileID,'%d');
fclose(fileID);
end
Più risposte (0)
Vedere anche
Categorie
Scopri di più su Low-Level File I/O in Help Center e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!