Importing multiple csv files, giving them new names and extracting different columns of data to form seperate datastrings
2 次查看(过去 30 天)
显示 更早的评论
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
0 个评论
采纳的回答
Iain
2013-8-28
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...
0 个评论
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Genomics and Next Generation Sequencing 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!