How to populate a n-d lookup table from the workspace in R2011b?
2 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
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 commentaires
Réponses (1)
Arnab Sen
le 31 Déc 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')
>> 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 commentaires
Voir également
Catégories
En savoir plus sur Lookup Tables dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!