How to retrieve a matched element or a number in lookup table

sir,
deg sine_value cosine_value; 0 0 1; 30 0.5 0.866; 45 0.707 0.707; 60 0.866 0.5 ; 90 1 0;
with reference to above lookup table,
if i enter 2nd column element and 3rd column element for search, it is working fine and we are getting in which row they are present.
suppose the search is made for element present in 2nd colum and an element present in 3rd column then, by using the following formula
[mindiff, row] = min( (YourTable(:,2) - V1).^2 + (YourTable(:,3) - V2).^2 );
we can able to find in which row they are present. But, task is we need to retrieve the element which is present in 1st column present in the matched row(i.e., row x 1 element should be retrieved and stored in a variable).
for example: from the above formula, if we enter V1=0.5, and V2=0.866.. then, we can able to find row=2. but the task is we have to retrieve the element present in 1st column and the matching row(i.e., we have to retrieve 30 for this example). please help me for this problem.
thanks reddy

4 件のコメント

Jan
Jan 2012 年 7 月 9 日
The question would be more clear, if you provide YourTable in valid Matlab syntax.
Reddy
Reddy 2012 年 7 月 9 日
編集済み: Reddy 2012 年 7 月 9 日
look up table for above question
(All bold characters are in 1st column, all italics characters are in 2nd column and normal font are in 3rd column)
deg sine_value cosine_value
0 0 1
30 0.5 0.866
45 0.707 0.707
60 0.866 0.5
90 1 0
the above table resembles to basic trigonometric sine and cosine values for standard values.
Jan
Jan 2012 年 7 月 9 日
編集済み: Jan 2012 年 7 月 9 日
It is not clear how "deg" and "o" are stoired in the same array. Is it a cell srtring and both are strings? An example for valid Matlab syntax:
YourTable = [0, 0, 0; 30, 05, 0.866; etc]
or
YourTable = {'deg', 'sine_value', 'cosine_value'; ...
0, 0, 0; 30, 05, 0.866; etc}
or whatever meest the array you use. The less we have to guess, the more efficient is the creation of a helpful answer.
Reddy
Reddy 2012 年 7 月 9 日
the first one is correct. i.e., YourTable = [0, 0, 0; 30, 05, 0.866; etc] is the correct choice of lookup table... please help me to find the answer which i have described earlier today for this lookup table.. thanks, sridhar

サインインしてコメントする。

 採用された回答

TAB
TAB 2012 年 7 月 9 日
編集済み: TAB 2012 年 7 月 9 日

0 投票

TrigTable = [ 0 0 1.0000
30.0000 0.5000 0.8660
45.0000 0.7070 0.7070
60.0000 0.8660 0.5000
90.0000 1.0000 0];
V1=0.5;
V2=0.866;
SineIdx = find(TrigTable(:,2)==V1);
CosineIdx = find(TrigTable(:,3)==V2);
if SineIdx==CosineIdx
AngleDeg = TrigTable(SineIdx,1);
end

その他の回答 (0 件)

カテゴリ

ヘルプ センター および File ExchangeTables についてさらに検索

タグ

質問済み:

2012 年 7 月 9 日

Community Treasure Hunt

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

Start Hunting!

Translated by