Effacer les filtres
Effacer les filtres

Importing multiple csv files, giving them new names and extracting different columns of data to form seperate datastrings

2 vues (au cours des 30 derniers jours)
I'm new to using Matlab and found out how to inmport data, rename it and substract different columns out of it, but I would like to know how I can properely use the loop tool to be able to extract different columns and name the datastrings for multiple files. Underneath is the code I used for one file just rewritten for all cases. It works with limited number of importing files, however with to many I run out of memory. Can somebody give me tips how to use loops to make sure the .csvfiles are imported automatically and the names of different columns of these files are are automaticaly generated and renamed either?
Thanks for the help, Rianne
Importdir=dir('*.CSV');
M1=Importdir(1).name;
M2=Importdir(2).name;
M3=Importdir(3).name;
M4=Importdir(4).name;
M5=Importdir(5).name;
M6=Importdir(6).name;
M7=Importdir(7).name;
M1=csvimport (M1);
M1_S3D_S1_D=M1(:,3);
M1_S3D_S1_UV=M1(:,4);
M1_S3D_S1_VV=M1(:,5);
M1_S3D_S1_WV=M1(:,6);
M2=csvimport (M2);
M2_S3D_S1_D=M1(:,3);
M2_S3D_S1_UV=M2(:,4);
M2_S3D_S1_VV=M2(:,5);
M2_S3D_S1_WV=M2(:,6);
%and so on

Réponse acceptée

Iain
Iain le 28 Août 2013
Importdir=dir('*.CSV')
for i = 1:numel(Importdir);
M = Importdir(i).name;
M =csvimport (M);
M_D{i} = M(:,3);
M_U{i} = M(:,4);
M_V{i} = M(:,5);
M_W{i} = M(:,6);
end
If you have too many files, you'll still run out of memory...

Plus de réponses (0)

Catégories

En savoir plus sur Genomics and Next Generation Sequencing 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!

Translated by