I've written a program in which it is necessary to delete some points from a matrix if they exist. sometimes, there are more than one copy of them in the matrix. But the problem is that when it comes to check whether those points are in the matrix , matlab can't recognize them in the matrix although thery are exist.
Let's begin from these commands and their echos. In the following, "intersections" function gets the intersection points.
[points(:,1) points(:,2)] = intersections(obj.modifiedVGVertices(1,:), obj.modifiedVGVertices(2,:), ...
[vertex1(1) vertex2(1)],[vertex1(2) vertex2(2)]);
points
vertex1
vertex2
Their echo:
points =
12.0000 15.0000
33.0000 24.0000
33.0000 24.0000
vertex1 =
12
15
vertex2 =
33
24
Two points(that are vertex1 and vertex2) should be eliminated from the result. it should be done by the below commands:
points = points((points(:,1) ~= vertex1(1)) | (points(:,2) ~= vertex1(2)),:);
points = points((points(:,1) ~= vertex2(1)) | (points(:,2) ~= vertex2(2)),:);
After doing that, we have this unexpected outcome:
points =
33.0000 24.0000
The outcome should be an empty matrix. As you can see, the first(or second?) pair of [33.0000 24.0000] has been eliminated, but not the second one.
Then I checked these two expressions:
points(1) ~= vertex2(1)
ans =
0
points(2) ~= vertex2(2)
ans =
1 <-----It means 24.0000 is not equal to 24.0000?
What is the problem?
To become more and more surprised, I made a new script that has only these commands:
points = [12.0000 15.0000
33.0000 24.0000
33.0000 24.0000];
vertex1=[12 ; 15];
vertex2=[33 ; 24];
points = points((points(:,1) ~= vertex1(1)) | (points(:,2) ~= vertex1(2)),:);
points = points((points(:,1) ~= vertex2(1)) | (points(:,2) ~= vertex2(2)),:);
points
The result:
points =
Empty matrix: 0-by-2