I want to run a Simulink model from a MATLAB function. The Simulink model contains a model reference block.
However, when I execute the following commands in my MATLAB function:
opt = simset('SrcWorkspace','Current');sim('MainTest',1,opt);
I get the following error message:
??? Error using ==> RunTheModel at 6 Error due to multiple causes: --> Error using ==> tlc_c at 116 Error evaluating parameter 'Gain' in 'ReferedTest/Gain': Error using ==> rtwgen Undefined function or variable 'a'. --> Error while bringing model references of model MainTest up to date: Error using ==> tlc_c at 116 Error evaluating parameter 'Gain' in 'ReferedTest/Gain': Error using ==> rtwgen Undefined function or variable 'a'. Caused by: Error using ==> RunTheModel at 6 Error using ==> tlc_c at 116 Error evaluating parameter 'Gain' in 'ReferedTest/Gain': Error using ==> rtwgen Undefined function or variable 'a'. Error using ==> RunTheModel at 6 Error while bringing model references of model MainTest up to date: Error using ==> tlc_c at 116 Error evaluating parameter 'Gain' in 'ReferedTest/Gain': Error using ==> rtwgen Undefined function or variable 'a'.
Best Answer