read csv file in sequence and post process data

19 ビュー (過去 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 Center および File ExchangeShifting and Sorting Matrices についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by