How to populate a n-d lookup table from the workspace in R2011b?

조회 수: 1 (최근 30일)
Mark Baker
Mark Baker 2015년 12월 9일
답변: Arnab Sen 2015년 12월 31일
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.

답변 (1개)

Arnab Sen
Arnab Sen 2015년 12월 31일
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')
>> assignin(hws,'a',5);
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:

카테고리

Help CenterFile Exchange에서 Lookup Tables에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by