Rapid Accelerator Error with App Designer Simulink Compiler

14 views (last 30 days)
Hi Everyone,
I'm building an app that uses simulink (I have a lookup table and that's the best way to do it) with app designer. The thing is that if I want to use the app as a standalone desktop app I have to build the simulation in rapid accelerator mode but when I test it/compile it (with simulink compiler, available since r2020a) I get an error code I cannot get rid off. I have tried everything, all the answers given in this forum from other users with issues related to rapid accelerator error have been tried and also changing the solver settings in the model.
The code is as follows:
Stroke=(0:1:105)
Front_rate=6;
FrontFluidLevel=200;
Table=FluidLevel_Lookup_Table;
SimIn=Simulink.SimulationInput('Balance_slk');
SimIn=SimIn.setVariable('Stroke',Stroke);
SimIn=SimIn.setVariable('Front_rate',Front_rate);
SimIn=SimIn.setVariable('FrontFluidLevel',FrontFluidLevel);
SimIn=SimIn.setVariable('Table',Table);
SimIn=SimIn.setModelParameter('StopTime',10);
SimIn = simulink.compiler.configureForDeployment(SimIn);
SimOut = sim(SimIn);
The error code I'm getting is this one:
Error using Simulink.BlockDiagram.buildRapidAcceleratorTarget (line 37)
Error due to multiple causes.
Error using Simulink.BlockDiagram.buildRapidAcceleratorTarget (line 37)
Invalid setting in 'Balance_slk/FrontFluidLevel' for parameter 'Value'.
Error using Simulink.BlockDiagram.buildRapidAcceleratorTarget (line 37)
Error evaluating parameter 'Value' in 'Balance_slk/FrontFluidLevel'
Error using Simulink.BlockDiagram.buildRapidAcceleratorTarget (line 37)
Unrecognized function or variable 'FrontFluidLevel'.
Error using Simulink.BlockDiagram.buildRapidAcceleratorTarget (line 37)
Variable 'FrontFluidLevel' does not exist.
Anyone who can deliver some light here would be highly appreciated.
Many thanks in advance!!!

Answers (1)

Sherif Tolba
Sherif Tolba on 14 Jul 2021
I understand that you are trying to deploy an app that you created in App Designer for your model as a standalone desktop app and are getting an error.
The error is most likely due to the fact that these variables are not defined in the base workspace/data dictionary or model workspace. Even though the variables are specified on the SimulationInoput object they are not available during rapid accelerator build. The model should be able to be compiled by itself without relying on SimulationInput object.
To make it work, you need to define such variables and give them initial values using one of these techniques:
  • Option 1: Data dictionary
Define these variables in a data dictionary and use it in your model
  • Option 2: Initialization script
Create an M-File, e.g. modelInit.m, that defines and initializes these variables
Call it from the model's PreLoadFcn (you can also initialize these variables right inside the textarea of that function)
  • Option 3: Inside your app
Use assignin('base', 'Stroke', 0:1:105) in your app's code (before the model is loaded) to define and assign these variables in the base workspace
Thanks,
Sherif

Categories

Find more on Interactive Model Editing in Help Center and File Exchange

Products


Release

R2020a

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!