how to concatenate a result of a loop to a single 2D mtrixa
1 vue (au cours des 30 derniers jours)
Afficher commentaires plus anciens
Hi, I have the following code to find the linear index and the associated values of connected points in a matrix
a=[0 1 1 0 0 0
1 1 1 0 2 2
0 0 0 0 2 2
0 0 0 0 0 0]
a_connected=bwlabeln(a);
%region properties of matrix a
cc2=bwconncomp(a_connected);
stats_a=regionprops(cc2,'pixellist','pixelidxlist');
% Extracting the connected objects and their index information
% For Test Matrix
arr_test=[];
tss=[];
for k=1:numel(stats)
idx_test=stats(k).PixelIdxList;% gives linear index
Pixels_in_region_test=test_connected(idx_test);% associated val
arr_test=[idx_test,Pixels_in_region_test]
end
I want to create an output matrix that will store the result of loop but so far been unable. the matrix only stores the value from the final iteration of the loop. I have used cat but it does not work.
Any ideas on how to or what i am doing wrong?
Thanks
0 commentaires
Réponse acceptée
Plus de réponses (0)
Voir également
Catégories
En savoir plus sur Creating and Concatenating Matrices 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!