MATLAB: Change the order of array change the order I have M=[1,2 ;1,5; 2,4;2,5;4,5; 4,9;5,6;6,11;9,10;10,11] I want to change the order of numbers I want this answer N=[1,2;1,4;2,3;2,4;3,4;3,6;4,5;5,8;6,7;7,8] Best Answer [~,N] = ismember(M,unique(M(:))) Related SolutionsMATLAB: Find cycle in array This can be done using the spatialgraph2D submission on the File Exchange,https://www.mathworks.com/matlabcentral/fileexchange/73630-spatialgraph2dM = [1,2 ;1,5; 2,4;2,5;4,5; 4,9;5,6;6,11;9,10;10,11]G = graph(M(:, 1), M(:, 2));hg=plot(G);obj=spatialgraph2D(G,hg.XData,hg.YData);[~,A]=obj.polyshape;>> A{:}ans = 1 5 2ans = 2 5 4ans = 4 5 6 11 10 9 >> obj.mosaic MATLAB: How to calculate the mean of the elements values of the array according to objects of the other array. A is your labeled matrix. B is your intensity matrix. Use regionprops() (in the Image Processing Toolbox) and ask for MeanIntensity:A = [3 3 3 3 1 1 1 1 1 1 8 8; 3 3 3 5 1 1 1 1 1 8 8 8; 3 3 3 5 5 1 1 1 8 8 8 8; 3 3 3 5 5 5 1 8 8 8 8 8; 7 7 7 5 5 5 6 6 6 8 8 8; 7 7 7 5 5 5 6 6 6 4 4 4; 7 7 2 2 2 6 6 6 6 4 4 4; 7 2 2 2 2 6 6 6 6 4 4 4; 2 2 2 2 2 2 6 6 4 4 4 4]B = [5 4 4 3 7 5 8 8 7 9 4 8; 6 8 9 4 2 3 6 7 7 7 6 8; 7 2 4 7 7 9 4 2 4 8 8 9; 8 2 4 2 6 5 2 8 1 1 7 9; 4 8 2 8 8 3 2 2 6 2 5 8; 1 1 3 1 6 4 5 6 2 7 3 1; 7 7 3 5 9 7 4 5 7 7 7 1; 3 7 9 1 4 4 7 2 5 7 4 1; 8 4 3 7 4 2 1 1 3 5 6 3]props = regionprops(A, B, 'MeanIntensity')allIntensities = [props.MeanIntensity]C = zeros(size(A))for k = 1 : max(A(:)) C(A==k) = allIntensities(k);endC % Print to command window. Related QuestionSum values corresponding to a number in a vectorHelp running Matlab scriptFind set of values that are unique to the values in another columnDivide an array in n different arraysMatlab solve indeterminate polynomial equations numerically
Best Answer