Calling a opening function in a programmatic GUI

13 次查看(过去 30 天)
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 个评论
Luna
Luna 2019-2-23
Can you share the code? and the script how you call it?
E. H.
E. H. 2019-2-25
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...

请先登录,再进行评论。

回答(1 个)

Krishna Zanwar
Krishna Zanwar 2019-2-26
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.

类别

Help CenterFile Exchange 中查找有关 Whos 的更多信息

产品

Community Treasure Hunt

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

Start Hunting!

Translated by