Azzera filtri
Azzera filtri

Calling a opening function in a programmatic GUI

4 visualizzazioni (ultimi 30 giorni)
E. H.
E. H. il 23 Feb 2019
Commentato: E. H. il 28 Feb 2019
I designed a GUI programmatically that gets called in a script with an input argument.
For initalising before any of the GUI gets executed I would like to call an opening function and an output function, in the same way it's done, when I design a GUI with the tool GUIDE.
I have the suspicion, that my opening function doesn't gets executed and so it's impossible for me to work with passed input arguments from the script
Is that possible?
  2 Commenti
Luna
Luna il 23 Feb 2019
Can you share the code? and the script how you call it?
E. H.
E. H. il 25 Feb 2019
thank you for your fast answer, luna... I wrote a code example for the script and the GUI, how I'd like it to work... the varargin and varargout are still troubling me...

Accedi per commentare.

Risposte (1)

Krishna Zanwar
Krishna Zanwar il 26 Feb 2019
Hi,
The error in this code is caused in the function calc_button_callback as the variables a, b, c are not initiated. I am not sure what to replace these variables with, so I just put a constant there.
There is no output to the function gui. You can just remove the varargout from the function declaration or you have to make sure that you set some value to varargout.
If these two changes are made the errors in the function are resolved.
Varargin is used when you don’t know how many input arguments to expect when the function is called. Varargin acts as a Cell array of all the input arguments no matter how many are called. But if you have a difficulty working with varargin you can just replace it with normal variables as you already know how many variables are called. Same goes with varargout.
There are some basic coding mistakes in your code which need to be corrected.
For example, while defining the calc_button_callback you are taking handles as an input but you are not passing handles while calling the function.
Here are some links that should help you understand the functions properly.
  1. Callbacks examples.
  2. Varargin, varargout.
  3. Functions.

Categorie

Scopri di più su Migrate GUIDE Apps in Help Center e File Exchange

Prodotti

Community Treasure Hunt

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

Start Hunting!

Translated by