How do I call a function from the MATLAB Editor into AppDesigner
5 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
I have written a few functions in MATLAB's script Editor and I want to call these functions in AppDesigner. Is there any way of doing this without changing the internals of the functions? For example, if I'm using a plot function to plot a simple straight line graph, how can I call this function in AppDesigner?
0 comentarios
Respuestas (2)
M
el 22 de Mayo de 2018
I don't know exactly what you mean by "without changing the internals of the functions", but in the CodeView of AppDesigner, you can call your function in the same way as you would do it in the editor.
0 comentarios
Ameer Hamza
el 22 de Mayo de 2018
If your function does not interact with the graphic elements of the app and just give you a non graphic output then you can simply call your function inside the App designer callback functions without any modification. For example, if you have defined a function myFunction() and it is placed in MATLAB path then you can simply call this function inside the app designer callback functions
function ButtonPushed(app, event)
output = myFunction()
end
But if your function needs to interact with the components of the app then you will need to make some modification. For example, to plot on the axes component of App Designer, you will need to call it as follows
plot(app.UIAxes, x, y) % you need to explicitly specify the axes, whereas normally it is optional.
Similarly, all function trying to modify the App designer components will need access to the app object and then they will be able to make any modification to the app component. The easiest way to do that is to add an extra input to myFunction() i.e. change the definition as
function output = myFunction(app, previous_inputs)
% old code
plot(app.UIAxes, x, y)
end
In this way with little modification, you can make your own function to interact with the app components.
2 comentarios
sean borgsteede
el 31 de En. de 2019
I too am running into this problem. I have scripts that I tend to use without the GUI and I also would like to use them in the GUI. Due to that, I have a folder of functions that need to be in my path during GUI execution. This works just great on my computer, but if I package it(exe or app), how do I ensure these external files will be in my path once the app/exe is installed?
Ver también
Categorías
Más información sobre Develop Apps Using App Designer en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!