Appdesigner: Remove Simulink dependency

46 visualizaciones (últimos 30 días)
Giulio Giovannetti
Giulio Giovannetti el 7 de Ag. de 2024
Comentada: Giulio Giovannetti el 21 de Ag. de 2024
Hi everybody,
I have accidentaly added a Simulink component to my app and now I cannot compile it anymore.
I have the MATLAB compiler but not the Simulink compiler, to overcome the problem I have removed the simulink component but the dependency is still there, hence the appdesigner does not allow me to compile the app.
Is there any trick that I can use to fix this problem?
Best regards,
Giulio

Respuesta aceptada

Rahul
Rahul el 8 de Ag. de 2024
I was able to reproduce your issue at my end.
As mentioned by you, after removing a Simulink component from the AppDesigner app, the Simulink dependancy still exists and might cause an issue if Simulink compiler is not present.
I have created a basic AppDesigner app to reproduce this issue:
This app only contains a Simulation Controls component in it's UI Figure.
After adding this component to the app, in the 'Code view' of the app we can see additional code for establishing dependancies with Simulink:
Additional code in 'Code View' 1:
% Properties that correspond to app components
properties (Access = public)
UIFigure matlab.ui.Figure
SimulationControls simulink.ui.control.SimulationControls % This line is added to set the properties of the component which is added
end
Additional code in 'Code View' 2:
% Public properties that correspond to the Simulink model
properties (Access = public, Transient)
Simulation simulink.Simulation
end
% These public properties are established corresponding to the Simulink
% model connected
Additional code in 'Code View' 3:
% Construct app
function app = app1
% Associate the Simulink Model
app.Simulation = simulation('sim');
% Create UIFigure and components
createComponents(app)
% Register the app with App Designer
registerApp(app, app.UIFigure)
if nargout == 0
clear app
end
end
% Inside the app function, the app.Simulation = simulation('') line is
% added which establishes the connection of the app with the Simulink model.
%Here my Simulink model's name is 'sim.slx' that's why 'sim' is mentioned
%in the simulation function.
After removing the Simulation Controls component from the app, we can see in the 'Code view' of the app that the Additional code added in 'Code view' 1 is removed, however the Additional code added in 'Code View' 2 and 3 still exists and is creating the Simulink dependency.
A possible workaround for this case can be:
From the 'Designer' Tab of your app you can go to Save -> Export to .m File. This step is required as you cannot manually make changes to the code in the 'Code View' app, however you can edit a .m file according to your needs.
So after creating a .m File for your app, you can remove the lines containing Additional code in 'Code View' 2 and 3.
This would remove the dependency of Simulink from your app in your .m file. You can now run your app by running the .m File.
Hope this helps! Thanks.
  1 comentario
Giulio Giovannetti
Giulio Giovannetti el 8 de Ag. de 2024
Thank you @Rahul for the support!
As far as I understood, this process allows the dependency removal but the exported m-version app cannot be imported again so I could no longer use the appdesginer for further improvemenet. By the way I can continue developing my app with the appdesigner and implement this process just to compile the app.
In any case, I have just opened a bug fixing issue with Mathworks.

Iniciar sesión para comentar.

Más respuestas (2)

Evelyn
Evelyn el 8 de Ag. de 2024
Editada: Evelyn el 11 de Ag. de 2024
Hello @ tiny fishing,
To remove the Simulink dependency from your app and allow it to compile successfully using the MATLAB Compiler, you can try the following steps:
1.Clean Up Unused Functions and Blocks:
  • Make sure that you remove any unused functions or blocks from your app that might still be referencing Simulink components.
2. Check Dependencies in AppDesigner:
  • Open your app in AppDesigner and go to the "Code View" tab.
  • Manually inspect the code to ensure there are no references to Simulink components.
3. Update Compiler Options:
  • Check the compiler options in the MATLAB Compiler to ensure that it is not trying to include Simulink dependencies.
4. Rebuild the App:
  • Try rebuilding your app after making sure that all references to Simulink components are removed.
  1 comentario
Giulio Giovannetti
Giulio Giovannetti el 8 de Ag. de 2024
Thank you Evelyn for your support!
Using the dependency analyzer tool I found some lines referring Simulink in the class definition properties.
% Public properties that correspond to the Simulink model
properties (Access = public, Transient)
Simulation simulink.Simulation
end
Unfortunately, these lines cannot be deleted manually...

Iniciar sesión para comentar.


Christopher
Christopher el 17 de Ag. de 2024
Does anyone have a solution to removing the Simulink dependency? It cannot be manually removed due to the grayed out App Designer code.
  1 comentario
Giulio Giovannetti
Giulio Giovannetti el 21 de Ag. de 2024
While waiting for this issue to be fixed I am following @Rahul's suggestion.

Iniciar sesión para comentar.

Categorías

Más información sobre Simulink Environment Customization en Help Center y File Exchange.

Productos


Versión

R2024a

Community Treasure Hunt

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

Start Hunting!

Translated by