Unrecognized function or variable when calling a LinearModel from a Simulink Interpreted Function block
조회 수: 3 (최근 30일)
이전 댓글 표시
I have a Simulink block that previously called a "Scattered Interpolant" function with 3 inputs using a Interpreted Function block in 2021a. I have added that function to the "base" workspace with the assignin command from Matlab. But when I replaced the "Scattered Interpolant" with a "LinearModel" with 5 inputs (created with fitlm and also added to the "base" workspace memory), I now get the errors:
An error occurred while running the simulation and the simulation was terminated
Caused by:
- Error due to multiple causes.
- Unrecognized function or variable 'TB3_C'.
- Error in 'flow [kg//s]' while evaluating expression.
I presume that fitlm models are available to Simulink? What else could I have done wrong?
댓글 수: 2
답변 (1개)
Jon
2023년 10월 12일
편집: Jon
2023년 10월 12일
When I make an example following the steps you provide it runs without errors. Please attach your script, and Simulink model.
If you create or load TB3_C using a script (rather than a function) then I think it will already be in the base workspace, so the assignin seems redundant.
By the way, you can also use TB3_C.predict([0,0,7,0,0,0]) inside of your interpreted MATLAB function block rather than feval
댓글 수: 6
Jon
2023년 10월 13일
I would start by looking in your Workspace browser (tab on desktop) checking whether TB3_C is even there. I don't think it will be, because the error message is telling you the variable doesn't exist. Then try to just load the .mat file (I'm assuming from what you said that TB3_C is supposed to be in a .mat file) that you think has TB3_C in it and see if it is in the workspace. You can also right click on the .mat file and choose show details to see what is in the file, maybe TB3_C isn't even in there. Otherwise, most likely you have a small typo, for example a lower case where it should be capitalized in an assignment statement so perhaps you have an object called Tb3_C or TB3_c
참고 항목
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!