
Use Preelokup and n-Direct Lookup Table blocks in Simulink without interpolation
2 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
Adrian
el 30 de En. de 2025
Comentada: Adrian
el 3 de Feb. de 2025
Hi,
I want to create a lookup table that based on some inputs, where the indeces of the lookup table are found and the field value is output.
I attach the lookup table I made with its corresponding breakpoints.
I am using two Preelokup blocks to find the indeces of this 2D table. These indices are used then as input to the Direct LookupTable block (see the attached block diagram picture).
My issue is that if I input e.g., 28 in "in1", the index found is correct. However, if I put a value within two breakpoint values (e.g., 30) it uses interpolation, flat or rounding, and I would like to avoid that. Is there a way where if the input value does not match with any of the breakpoints array it simply does not return any index or the Lookup table simply returns no value or a zero?
Thanks in advance
0 comentarios
Respuesta aceptada
Gayathri
el 3 de Feb. de 2025
The 1-D, 2-D, and n-D "Lookup Table" blocks evaluate a sampled representation of a function in N variables where the function F can be empirical.Hence, there is no option as of now to return a value of zero, if the input values does not match the breakpoints array mentioned in the "Lookup Table". In such cases it would be better to use a "MATLAB Function" block where you can define the breakpoints and the table data. You can find the code as shown below.
function output = exactMatchLookup(in1, in2)
breakpointsX=[29 45 65 78 99]; %fill in the breakpoints
breakpointsY=[2 3 4 5 6]; %fill in the breakpoints
tableData=[4 5 6 22 10;16 19 20 3 20;10 18 23 5 40;5 9 88 4 50;7 34 67 99 40];
idxX=0;
idxY=0;
for i = 1:length(breakpointsX)
if breakpointsX(i) == in1
idxX = i;
break; % Exit loop once the index is found
end
end
% Check if in2 is in breakpointsY and find the index
for j = 1:length(breakpointsY)
if breakpointsY(j) == in2
idxY = j;
break; % Exit loop once the index is found
end
end
% Check for exact match
if idxX==0 || idxY==0
output = 0; % Default value if no exact match
else
output = tableData(idxX, idxY); % Lookup table value
end
end
Then you can design the model as shown in the screenshot below.

For more information on "Lookup Tables", please refer to the documentation link below.
Hope you find this information helpful!
Más respuestas (0)
Ver también
Categorías
Más información sobre Lookup Tables en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!