How to populate a n-d lookup table from the workspace in R2011b?
2 ビュー (過去 30 日間)
古いコメントを表示
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.
2 件のコメント
回答 (1 件)
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:
0 件のコメント
参考
カテゴリ
Help Center および File Exchange で Lookup Tables についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!