Reversing a 2D lookup table using S-fuction in Simulink
Ältere Kommentare anzeigen
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 Kommentare
Ryan Livingston
am 9 Apr. 2014
Bearbeitet: Ryan Livingston
am 9 Apr. 2014
Could you please elaborate on "but it didn't work"? Were there errors? If so what were they? Is the answer unexpected?
Aaron
am 10 Apr. 2014
Antworten (1)
Titus Edelhofer
am 9 Apr. 2014
0 Stimmen
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
Kategorien
Mehr zu String finden Sie in Hilfe-Center und File Exchange
Produkte
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!