How to populate a n-d lookup table from the workspace in R2011b?
4 views (last 30 days)
Show older comments
Mark Baker on 9 Dec 2015
If I enter the values directly in the n-d lookup block, it works, but if I enter parameter names in the lookup block I get "Undefined function or variable " ", but I know it IS defined and present in the workspace.
Arnab Sen on 31 Dec 2015
I understand that you would like to put some variables in 'Table data' parameter of 'n-D Lookup Table' block and simulate the model, but you observe error 'undefined variable or function' while trying to do so.
This issue may occur if the variables is not in the workspace of the model as the model can access only the variables from its own workspace.
You can use in-built 'assignin' function to set a variable in a particular workspace. You may execute the following code snippet in MATLAB command Window for demonstration purpose:
% Suppose the name of the model under consideration is 'sampleModel' and the variable name is 'a':
>> hws = get_param('sampleModel','modelworkspace')
Now, set the 'Table Data' parameter if 'n-D Lookup Table' as 'reshape(repmat([4 a 6;16 19 20;10 18 23],1,2),[3,3,2])' and simulate the model.
For more details about the functions 'assignin' and 'get_param', refer to the following links:
Find more on Lookup Tables in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!Start Hunting!