Calling a opening function in a programmatic GUI

조회 수: 13 (최근 30일)
E. H.
E. H. 2019년 2월 23일
댓글: E. H. 2019년 2월 28일
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