Removing Points Along a Diagonal Line

I have a slope that i have discretized into points. However along the diagonal line I would like to remove all the points to the right of this line. Is this possible? All I have been able to do is remove the points as shown in the second figure but my slope actually looks like the first figure. The points to be reomved are all those lying within the shaded region. Is this possible?

답변 (1개)

infinity
infinity 2019년 7월 30일

0 개 추천

Hello,
I would suggest you a solution,
Since you have known two points of slope, which are (40,35) and (74.4, 15), you can easily get a segment passing to these points. Let say, y = ax + b.
Then, you can define a function, for example phi(x,y) = ax + b - y. As it can seen that phi(x,y) > 0 if (x,y) is in the left of the slope and phi(x,y) < 0 if (x,y) is in the right of the slope and phi(x,y) = 0 if (x,y) is in the slope. This technique is called "levelset method".
Now, what you can do is to use the phi funtion to check a point is in the left or the right of the slope. If it is in the right, you just eleminate it.

댓글 수: 5

racqs
racqs 2019년 7월 31일
Thanx for your feedback. But now I have two arrays of different dimensions. One that contains all the x,y coordinates and one containing only those which should be removed. For example
A = [ 14.25 1.25
14.75 1.25
15.25 2.25
15.75 2.25
.........
90.25 14.25
90.75 14.75]
B = [17.25 0.25
17.75 0.25
18.25 0.75
18.75 0.75]
where the x coordinates are listed on the left and the y coordinates on the right. The values of B to be removed exist in matrix A and I want to remove them so I am left with a new matrix without these values listed in B.
infinity
infinity 2019년 7월 31일
Hello,
What is your point in this comment?
You have A and B, A contains all nodes and B contains removed nodes. Then, what do you dealing with?
racqs
racqs 2019년 7월 31일
B contains the nodes I would like to remove from the full matrix A. I would like to get the remaining nodes. ie A without the nodes B
infinity
infinity 2019년 7월 31일
편집: infinity 2019년 7월 31일
Hello,
So, you could use for loop (or even don't need for loop) to check wheather a nodes in A is in B or not. If it is not, you store it into a new variable. For example,
clear
A = [1 2; 3 4; 5 6];
B = [3 4; 5 6];
C = [];
for i = 1:size(A,1)
if ~ismember(A(i,1),B(:,1)) || ~ismember(A(i,2),B(:,2))
C = [C; A(i,:)];
end
end
darova
darova 2019년 7월 31일
Read about inpolygon() also

댓글을 달려면 로그인하십시오.

카테고리

도움말 센터File Exchange에서 Operating on Diagonal Matrices에 대해 자세히 알아보기

질문:

2019년 7월 30일

댓글:

2019년 7월 31일

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by