Save different values of the same table from a loop

1 次查看(过去 30 天)
I have a table which is created from a loop.Problem is that overwrites the previous table for diffrent k and I dont know how to fix it.
for k=1:length(centroid_clust)
separate_areas(1,k)=[area_clust(k).Area];
c=[centroid_clust(k).Centroid];
text(c(1), c(2), sprintf('%d', k));
Cluster(k,:)=k;
Area_of_cluster(k,:)=area_clust(k).Area;
Eccentricity_of_cluster(k,:)=eccentricity_clust(k).Eccentricity ;
Euler_of_cluster(k,:)=euler_clust(k).EulerNumber;
Perimeter_of_cluster(k,:)=perimeter_clust(k).Perimeter;
Orientation_of_cluster(k,:)=orientation_clust(k).Orientation;
T2= table(Cluster,Area_of_cluster,Eccentricity_of_cluster,Euler_of_cluster,Perimeter_of_cluster,Orientation_of_cluster)
end

采纳的回答

KSSV
KSSV 2019-2-8
编辑:KSSV 2019-2-8
T2 = cell(length(centroid_clust),1)
for k=1:length(centroid_clust)
separate_areas(1,k)=[area_clust(k).Area];
c=[centroid_clust(k).Centroid];
text(c(1), c(2), sprintf('%d', k));
Cluster(k,:)=k;
Area_of_cluster(k,:)=area_clust(k).Area;
Eccentricity_of_cluster(k,:)=eccentricity_clust(k).Eccentricity ;
Euler_of_cluster(k,:)=euler_clust(k).EulerNumber;
Perimeter_of_cluster(k,:)=perimeter_clust(k).Perimeter;
Orientation_of_cluster(k,:)=orientation_clust(k).Orientation;
T2{k}= table(Cluster,Area_of_cluster,Eccentricity_of_cluster,Euler_of_cluster,Perimeter_of_cluster,Orientation_of_cluster)
end
  4 个评论
DIMITRIOS THEODOROPOULOS
i want to save k T2 tables ...This was my question....
so is it possible???
KSSV
KSSV 2019-2-8
you can save into mat file easily....if all yhe tables are of same size, you can merge them into single table and use writetable. If the tables are of different size, you can write them into different excel sheets using writetable

请先登录,再进行评论。

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Tables 的更多信息

标签

Community Treasure Hunt

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

Start Hunting!

Translated by