read csv file in sequence and post process data

3 vues (au cours des 30 derniers jours)
Carlos_conde
Carlos_conde le 15 Fév 2019
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.

Réponse acceptée

madhan ravi
madhan ravi le 15 Fév 2019
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

Plus de réponses (1)

Carlos_conde
Carlos_conde le 15 Fév 2019
Thanks a lot, you saved my day! :)

Catégories

En savoir plus sur Dates and Time 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