How to select corresponding value from an array?

조회 수: 3 (최근 30일)
Priya
Priya 2014년 5월 25일
편집: Priya 2014년 8월 6일
When I use the following expression for calculating theta I get a value in the range specified for theta below (i.e., 0.5 to 90).
Now based on the obtained value of theta, I have to choose the value of m and n correspondingly. And this must happen automatically, every time theta generates a value which will be close to the elements of the array 'theta' given below.
For e.g.(as in Bold), if theta =10, then my program should take m as 6.604 and n as 0.3112.
Please do help.

채택된 답변

Roger Stafford
Roger Stafford 2014년 5월 25일
If I interpret your word 'close' as meaning 'closest', then you can do this:
theta=[.5 1 1.5 2 3 4 6 8 10 20 30 35 40 45 50 55 60 65 70 75 80 85 90];
[~,p] = histc(acos(K_4./K_3)*180/pi,...
[-inf,(theta(1:end-1)+theta(2:end))/2,inf]);
m_selected = m(p);
n_selected = n(p);
This would still work if K_3 and K_4 are calculated as vectors.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Creating and Concatenating Matrices에 대해 자세히 알아보기

태그

제품

Community Treasure Hunt

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

Start Hunting!

Translated by