read csv file in sequence and post process data

조회 수: 2 (최근 30일)
Carlos_conde
Carlos_conde 2019년 2월 15일
답변: Carlos_conde 2019년 2월 15일
Hello all,
I have written a code manually to extract information regarding 5 matrices and postporcess the data (I want to get the maximun value of the column 11, . Each matrix has a different size (12 columns x around 300 rows).
The example of this code is:
T1 =csvread('contour_oh01_pe100.1.csv',1,0);
T2 =csvread('contour_oh01_pe100.2.csv',1,0);
T3 =csvread('contour_oh01_pe100.3.csv',1,0);
T4 =csvread('contour_oh01_pe100.4.csv',1,0);
T5 =csvread('contour_oh01_pe100.5.csv',1,0);
[M1,I1] = max(T1(:,11))
row1=T1(I1,:);
[M2,I2] = max(T2(:,11))
row2=T2(I2,:);
[M3,I3] = max(T3(:,11))
row3=T3(I3,:);
[M4,I4] = max(T4(:,11))
row4=T4(I4,:);
[M5,I5] = max(T5(:,11))
row5=T5(I5,:);
I am try to do it using a for-loop. But I am having problems to store the T1,T2,T3, T4 and T5:
for i=1:5
T(i)=[T,'num2str(n)']
[M(i),I(i)]=max(T(i)(:,11))
end
I hope that you may help me.

채택된 답변

madhan ravi
madhan ravi 2019년 2월 15일
T=cell(1,5); % preallocate
row=cell(1,5);
M=cell(1,5);
I=cell(1,5);
for k=1:5
T{k}=csvread(sprintf('contour_oh01_pe100.%d.csv',k),1,0);
[M{k},I{k}] = max(T{k}(:,11));
row{k}=T{k}(I{k},:);
end

추가 답변 (1개)

Carlos_conde
Carlos_conde 2019년 2월 15일
Thanks a lot, you saved my day! :)

카테고리

Help CenterFile Exchange에서 Dates and Time에 대해 자세히 알아보기

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by