MATLAB: How can i get a model argument from the modelworkspace into a matlab skript encapsulationmodel argumentsreferenced modelsscriptsimulink Hi, I want a script that calculates certain parameters from variables that I defined in the modelworkspace of a simulink model. How do I access these variables? Best Answer wksp = get_param(mdl,'ModelWorkspace')value = wksp.getVariable('K')... where "mdl" is your model's name :)- Sebastian Related SolutionsMATLAB: How to access variables in the model workspace from model callback functions Model callbacks such as "InitFcn" can by default, only access the base workspace. In order to access model workspace variables, you need to do something like (within the "InitFcn" for example):% Extract the model workspace objwksp = get_param('Model', 'ModelWorkspace'); % Extract the relevant model workspace variablenewVar = getVariable(wksp,'modelWkspVar'); MATLAB: Argument Question I think this is what they meant -In the function file:function outputVar = myfunction(inputVar)% write the rest of the program here, using inputVar as you would a stringWhen you call the function you give it a string:thisoutput = myfunction('data1.txt') Related QuestionModel block cannot be under a non-trivial mask since the model it references has grouped model arguments.How to discover all submodels within a simulink model programmaticallyAbout function argument
Best Answer