Concatenating Tables with Regionprops

2 visualizaciones (últimos 30 días)
S_run
S_run el 29 de Oct. de 2020
Editada: Ameer Hamza el 29 de Oct. de 2020
Hello,
I would like to concatenate multiple regionprops tables together that are generated one by one in a loop. However, I was not sure how to initialize the first table. What I did was create a table of zeros and assign all of the variable names. The error I am getting however is "Dimensions of arrays being concatenated are not consistent." Both tables are 1 by 33, but the error comes in from the centroid entry, for example. The centroid in regionprops has two entries, the x and y value, but the table I initialized only has one entry under centroids. How can I initialize the table such that the variable Centroid is assigned two entries? If that is not possible, is there a better way to go about concatenating regionprops tables that are generated in loop?

Respuesta aceptada

Ameer Hamza
Ameer Hamza el 29 de Oct. de 2020
Editada: Ameer Hamza el 29 de Oct. de 2020
Letting your table grow dynamically might not an efficient coding approach. It would be better if you save the tables in a cell array and then attach them together after the loops are completed. For example
regions = cell(1,n)
for i = 1:n
regions{i} = regionprops('table', ..)
end
all_regions = vertcat(regions{:});
Also, this approach does not require you to manually initialze the table.

Más respuestas (0)

Categorías

Más información sobre Creating and Concatenating Matrices en Help Center y File Exchange.

Community Treasure Hunt

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

Start Hunting!

Translated by