필터 지우기
필터 지우기

How to use If function to choose just some values of the matrix?

조회 수: 2 (최근 30일)
Beibit Sautbek
Beibit Sautbek 2016년 7월 1일
편집: KSSV 2016년 7월 1일
I have 10 points with x and y axis which is represented in matrix C: C =
11.1902 78.9215
43.7123 84.8152
26.2182 55.0542
89.4285 18.3821
41.1215 32.8977
62.8533 101.3337
26.5649 25.2378
70.1982 92.5817
36.2971 63.8342
75.4079 109.6135
The first column represents x axis, and second column indicates y axis.
I need to set conditions like:
If x positions of any 10 points is less than 5 or more than 60 (5>x>60),
cancel that point (x,y) from the matrix.
Actually I tried like this, but something is wrong:
if length(find(C(:,1)<5| C(:,1)>60))~=0
end
At the end results should be like this: C =
11.1902 78.9215
43.7123 84.8152
26.2182 55.0542
41.1215 32.8977
26.5649 25.2378
36.2971 63.8342

채택된 답변

KSSV
KSSV 2016년 7월 1일
편집: KSSV 2016년 7월 1일
C = [11.1902 78.9215
43.7123 84.8152
26.2182 55.0542
89.4285 18.3821
41.1215 32.8977
62.8533 101.3337
26.5649 25.2378
70.1982 92.5817
36.2971 63.8342
75.4079 109.6135] ;
x = C(:,1) ; y = C(:,2) ;
idx = find(x<5 | x>60) ;
C(idx,:) = [];
C =
11.1902 78.9215
43.7123 84.8152
26.2182 55.0542
41.1215 32.8977
26.5649 25.2378
36.2971 63.8342

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Annotations에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by