Why 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)?

2 views (last 30 days)
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: 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.

Accepted Answer

MathWorks Support Team
MathWorks Support Team on 29 Dec 2022
Edited: MathWorks Support Team on 30 Dec 2022
The ability to accept two vectors of different lengths is not supported by the '2-D Lookup Table' block.
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) MATLAB Function block
b) For Iterator Subsystem
The MATLAB Function block can be easily implemented using the "meshgrid" function. However, the For Iterator 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 this matrix and the operation involved. If a MATLAB Function 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 Iterator Subsystem 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, if code is generated for the model, the generated code will be different depending on the approach that is adopted.

More Answers (0)

Categories

Find more on Nonlinearity in Help Center and File Exchange

Products


Release

R2022b

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!