Info

이 질문은 마감되었습니다. 편집하거나 답변을 올리려면 질문을 다시 여십시오.

hi :) I need help , I have an array of float angles , I want to find the indexes of angles in the range -pi/M<theta<=pi/M thanks

조회 수: 1 (최근 30일)
I try the following code:
(The problem is that this gives me also theta = -pi/M )
tolerance = 10^-4
M = 4;
thetaindxes_in_range = find(abs((abs(theta(:,1))-pi/M)<=tolerance));% theta

답변 (1개)

Image Analyst
Image Analyst 2017년 6월 3일
Then don't use abs(). Do each comparison separately. Like this:
M = 4;
indexesInRange = (theta > -pi/M) & (theta <= pi/M)
theta_in_range = theta(indexesInRange)
  댓글 수: 3
fatema hamodi
fatema hamodi 2017년 6월 3일
sorry it's not working well because the following two lines code give the same result but they shouldn't give the same result because the second range contain also theta=-pi/M while the first didn't contain it
indexesInRange =(theta +pi/M>tol) & (theta-pi/M <= tol)
and
indexesInRange =(theta +pi/M>=tol) & (theta-pi/M <= tol)

이 질문은 마감되었습니다.

태그

Community Treasure Hunt

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

Start Hunting!

Translated by