Calling a function in App Designer
15 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
Gabriel
el 7 de Abr. de 2023
Respondida: Cris LaPierre
el 7 de Abr. de 2023
I have a function (let's call it 'results.m') and I would like to call it in an app I am creating. I want the inputs to be: filename, characteristic, and environment. These three inputs are set by 3 different Edit fields (text) in the app, and then after pressing the run button I would like to call the function with these three inputs, receive x and y data to plot, and then plot it. I am unsure of how to call the function and how to declare these three inputs as properties, and advice or tips?
0 comentarios
Respuesta aceptada
Cris LaPierre
el 7 de Abr. de 2023
Rather than having an external function, I would incorporate the function into your app. You can either incorporate it into the callback function for your Run button, or have it be a separate function in your app that is called by your run button callback. See here for creating a function in an app:
As for creating app properties, see here:
I would create X and Y as app properties, and rather than have your function return them, just update their values inside your function.
You can also call an external function, as Walter shows. You just need to make sure the function file is in the same folder as your *.mlapp file, or in a folder that has been added to your MATLAB path.
0 comentarios
Más respuestas (1)
Walter Roberson
el 7 de Abr. de 2023
filename = app.EditField1.Value;
characteristic = app.Editfield2.Value;
environment = app.Editfeild3.Value;
[x, y] = results(filename, characteristic, environment);
plot(app.UIAxes1, x, y);
title(app.UIAxes1, 'My plot');
There is no need to "declare" the inputs.
0 comentarios
Ver también
Categorías
Más información sobre Develop Apps Using App Designer en Help Center y File Exchange.
Productos
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!