how to concatenate a result of a loop to a single 2D mtrixa
Ältere Kommentare anzeigen
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
Akzeptierte Antwort
Weitere Antworten (0)
Kategorien
Mehr zu Creating and Concatenating Matrices finden Sie in Hilfe-Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!