a simple clasification of matrix elements
Show older comments
dear coleages, i got a problem with some elements, i`m working with a regular rectangle vertices, so, that's what i get:
%this are the table values of a regular rectangle vertices. are showed as row and cols %as the typical notation, as you see is formed by 4 rows and two cols which %correspond to coordinates X and Y (that`s why i use the name x1, x2,... xi and also %y1, y2, ...yi for each one)
x1=p(1,1); x2=p(2,1); x3=p(3,1); x4=p(4,1); y1=p(1,2); y2=p(2,2); y3=p(3,2); y4=p(4,2);
%continuing i have got the distances between each one. As you remember this is a %rectangle, and i have just three resulting distances.
A=sqrt((x2-x1)^2+(y2-y1)^2); B=sqrt((x3-x2)^2+(y3-y2)^2); C=sqrt((x3-x4)^2+(y3-y4)^2); D=sqrt((x4-x2)^2+(y4-y2)^2); E=sqrt((x3-x1)^2+(y3-y1)^2); F=sqrt((x4-x1)^2+(y4-y1)^2); G=sqrt((x3-x1)^2+(y3-y1)^2);
%i have make some order of the obtained distances values
V=[A B C D E F G]; W=sort(V); H=W'; %max to min ordering of obtained results and transposing
%the resulting H is a table which contains the distances between each coordinates, i have charged an example rectangle and i have obtained this values:
H= 102,08 102,08 928,45 928,45 934,05 934,05 934,05
OK, HEre comes my question:
I NEED TO CREATE A SCRIPT TO:
1)ELIMINATE THE REPEATED VALUES 2)REMOVE THE MAXIMUM AND MINIMUM VALUE /OR/ JUST TAKE THE CETRAL VALUE (928,45)
THANKS FOR YOUR HELP
Accepted Answer
More Answers (1)
Andrei Bobrov
on 19 Oct 2011
idxs = nchoosek(1:4,2)
H = sqrt(sum(abs(diff(reshape(p(idxs,:),size(idxs,1),[],2),1,2)).^2,3));
1.
[out1,a,b] = unique(H,'first')
2.
out2 = median(out1);
Categories
Find more on Logical in Help Center and File Exchange
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!