Read all files in directory & append columns from each to new matrix, unrelated filenames
2 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
I have several text files, each with 5 columns. I want to extract two columns from each file and append those columns to a new matrix, resulting in one final matrix that holds every pair of columns from every file in my directory. The columns are not next to each other in the text files. The filenames in my directory are not named chronologically. It does not matter what order the columns are appended to the new matrix. Can I loop through the directory without using filenames at all? This is what I tried:
myFiles = uigetdir('/Users');
for i =1:length(myFiles)
newT = dlmread(myFiles(i),'\t',[1 5 2916 5]); %read one column
newPres = dlmread(myFiles(i),'\t',[1 3 2916 3]); %read another column
for j=1:length(newT)
D(j) = [newT,newPres]; %append new columns to new matrix
end
end
I am new to matlab
0 commentaires
Réponses (0)
Voir également
Catégories
En savoir plus sur Startup and Shutdown dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!