How to implement a look up table in simulink which can accept variable SIZE data as inputs
25 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
Ganesh Iyer
el 11 de En. de 2023
Comentada: Ganesh Iyer
el 13 de En. de 2023
Hi.
How to implement a look up table in simulink which can accept variable SIZE data as inputs. So for example I am using a 1-D lookup table which ideally accepts a 15x1 vectors (each) as my table data and breakpoints. Both the vectors are monotonically increasing. This is the ideal condition. However, I also must do a data processing of the vectors before they are fed to the LUT. I want to remove zeros or negative numbers from one of the 2 vectors and I must shorten the other vector accordingly. Let's say for example I have one of the vectors with two 0s or two negative numbers, here I process the data so that I filter out these two vector elements and effective vector output size now is only 13 instead of 15 (for both the Table data and BP, i.e. I always make the size of these two vectors equal before using the LUT). This size can also now become 12 or 11 or 10 depending on how many invalid elements I have in my vector inputs. The LUT now does not accept variable size vectors a inputs as it always expects fixed sized Table data and BP.
Is there a solution for this? Is there a specific LUT type that I can use for this purpose?
Regards
Ganesh Iyer
2 comentarios
Paul
el 11 de En. de 2023
Editada: Paul
el 12 de En. de 2023
Hi Ganesh,
Suppose you start with 15 breakpoints. After the processing you end up with 13 breakpoints and 13 associated data points. Now, what should happen if the indepedent variable into the LUT is greater/lesser than the maximum/minimum breakpoint? Do you want to use the endpoint of the data points? Or extrapolate the data points?
Respuesta aceptada
Paul
el 12 de En. de 2023
Editada: Paul
el 12 de En. de 2023
Accroding to the doc, the LUT Dynamic block doesn't accept variable size signals.
I tried the following approach, which sounds like the path you might already be going down.
I tried this methos, which assumes that we want to clamp the independent variable to the endpoints of the table breakpoints when it is outside the breakpoints. The other blocks are Saturation Dynamic and Lookup Table Dynamic.
The Matlab Function block is:
function [maxxdata,minxdata,xdataout,ydataout] = fcn(xdatain,ydatain)
% remove points where xdatain = 0
% the leading elements of xdataout will be valid breakpoints. the trailing
% elements of xdataout are padding and shouldn't ever actually be used in LUT.
% the leading elements of ydataout will be the elements of ydatain that
% correspond to the good elements of xdatain
xdataout = 0*xdatain;
ydataout = 0*ydatain;
baddata = xdatain == 0;
numbad = sum(baddata);
numgood = numel(xdatain) - numbad;
maxxdata = max(xdatain(~baddata));
minxdata = min(xdatain(~baddata));
xdataout(1:numgood) = xdatain(~baddata);
xdataout(numgood+1:end) = (maxxdata + 1)*(1:numbad);
ydataout(1:numgood) = ydatain(~baddata);
end
Más respuestas (1)
Fangjun Jiang
el 12 de En. de 2023
You must be using the "Lookup Table Dynanic" block for this. Accordig to its doc, it does not support 'variable-size signals". So the answer is no.
There might be a solution using a MATLAB Function block, which supports variable-size signals. Both the break points data and table data are inputs to the MATLAB Functon block. Inside, use interp1() to do the lookup.
web(fullfile(docroot, 'simulink/slref/lookuptabledynamic.html'))
web(fullfile(docroot, 'simulink/ug/variable-size-signal-basics.html'))
3 comentarios
Fangjun Jiang
el 12 de En. de 2023
There is no direct way for "using variable size data with 1-D LUT simulink block", be it the "1-D Lookup Table" block, or the "Lookup Table Dynamic" block.
Check this out. web(fullfile(docroot, 'simulink/ug/guidelines-for-choosing-a-lookup-table.html'))
There is no mention of "variable-size data". A few options support "Dynamic breakpoint data" or "Dynamic table data".
You need to find a block that supports "variable-size data" to provide the "Dynamic breakpoint/table data". MATLAB Function block is one of them.
Ver también
Categorías
Más información sobre Nonlinear Operators 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!