MATLAB: Do I receive an error when I pass in 2 vectors of different lengths to the ‘2-D Lookup Table’ block in Simulink 7.2(R2008b)

simulink

I am trying to pass in 2 vectors of different lengths as inputs to the '2-D Lookup Table' block. However, when I try to simulate the model, I receive the following error message:
Error in port widths or dimensions. Invalid dimension has been specified for input port 1 of 'SimpleModel/Subsystem/<Current_ALT_SURF>3'.
Error in port widths or dimensions. Output port 1 of 'SimpleModel/Subsystem/2Stage Fuel Flow Array' is a one dimensional vector with 288 elements.
I would like the '2-D Lookup Table' block to return a matrix of all possible combination of the two inputs.

Best Answer

The ability to accept two vectors of different lengths is not supported by the '2-D Lookup Table' block in Simulink 7.2(R2008b).
The block does not loop through each possible input combination. The case is different in case of one scalar and one vector input when the scalar expansion rule applies - the '2D Lookup Table' block supports scalar expansion.
As a possible workaround, the matrix of values can be prepared in advance. This can be done using two methods:
a) Embedded MATLAB block
b) FOR loop iterating subsystem
The Embedded MATLAB block can be easily implemented using the MESHGRID function. However, the FOR loop iterating subsystem is more complicated, because all the values have to be put back together. We can use the fact that the '2D Lookup Table' block can handle scalar expansion to avoid using nested for loop.
Although either of the above two methods can be used, please note that the decision of the better approach of the above two depends on the size of his matrix and the operation involved.If Embedded MATLAB block with the MESHGRID function is used, it will create two buffers of the same signal and for large matrices this may cause a memory issue.
If the FOR loop iterating method is used, the '2D Lookup Table' block has to be called multiple times and it might increase the length of execution time.
In addition, code is generated for the model, the generated code will be different depending on the approach that is adopted.