Reversing a 2D lookup table using S-fuction in Simulink
古いコメントを表示
I would like to do a inversed 2D table lookup which was indicated as follows:
_____________
A--->| |
|2d-Looukup |--->C
B--->|___________|
____________
C--->| Reverse |
| lookup |--->B
A--->|___________|
I got online an idea that works, for example:
A=[17.9 18.0 18.1 18.2]'; B=[0.4 0.5 0.6 0.7]; C=[67 89 95 108 74 92 110 123 80 97 115 127 84 106 119 135];
A1=18.046; %Z=interp2(A,B,C,A1,B); Z=interp2(A,B,C',A1,B); C1=105; B1=interp1(Z,B,C1);
My question is that how can I code this idea to a S-funtion that can be used in my Simulink Model where A1 and C1 would be inputs? My S-function is listed as follows but it didn't work - appreicate if anyone can help - thanks.
function V = TD(A1,C1) %#codegen A = [17.9; 18.0; 18.1; 18.2]; B = [0.4, 0.5, 0.6, 0.7]; C = [67, 89, 95, 108; 74, 92, 110, 123; 80, 97, 115, 127; 84, 106, 119, 135];
Z = interp2(A,B,C',A1,B); V = interp1 (Z, B, C1);
2 件のコメント
Ryan Livingston
2014 年 4 月 9 日
編集済み: Ryan Livingston
2014 年 4 月 9 日
Could you please elaborate on "but it didn't work"? Were there errors? If so what were they? Is the answer unexpected?
Aaron
2014 年 4 月 10 日
回答 (1 件)
Titus Edelhofer
2014 年 4 月 9 日
0 投票
Hi,
inverting will be possible only if the strict monoticity is given. If this is the case, you will end up with a usual 2D-Lookup again. I would suggest to compute the values within MATLAB and use the 2D-Lookup block instead of an S-Function.
Titus
カテゴリ
ヘルプ センター および File Exchange で String についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!