필터 지우기
필터 지우기

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

채택된 답변

Iain
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개)

카테고리

Help CenterFile 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!

Translated by