Programming the push button

8 Ansichten (letzte 30 Tage)
sarfaraz
sarfaraz am 18 Mär. 2011
Hi!! Iam new to matlab and am making a project on CBIR. I am making the Gui using GUIDE, but am unable to code the push button.The purpose of the push button will be, if i press the button, it should call a m file that is already coded.Kindly leave a reply asap as am running outta time.
Thanks

Antworten (1)

Matt Fig
Matt Fig am 18 Mär. 2011
Put the name of the M-file in the callback function to the pushbutton. For example, if the M-file you wish to run is: myfile.m, then in the callback to the pushbutton, put the line:
myfile
Now if your M-file needs arguments passed to it, then you will need to make sure the data is available when the call is made. In order to help you do this, I would need to know the source of the data to be passed.
  2 Kommentare
Walter Roberson
Walter Roberson am 18 Mär. 2011
Putting the name of the mfile in as the callback is okay if whatever method you use to put it in interprets it as a string and creates code like,
... 'Callback', 'myfile', ...
However, if the method you are using to put in the value for the callback does not automatically construct what you give it as a string, then you should use @myfile so that the code gets constructed as
..., 'Callback', @myfile, ...
If the code were to get constructed as
..., 'Callback', myfile, ...
then at the time it tried to _set_ the callback, it would try to call myfile() and take whatever the return value was and use _that_ as the callback!
Matt Fig
Matt Fig am 18 Mär. 2011
@Walter, I wasn't talking about assigning the callback property as the M-file name.
The OP indicated that GUIDE was being used, so I meant to put the name of the M-file _in_ the callback function. With no more details than were given in the request, we don't know if the M-file will need to be invoked with arguments from other uicontrols, or its return value will need to be analyzed in the callback, etc.

Melden Sie sich an, um zu kommentieren.

Kategorien

Mehr zu Interactive Control and Callbacks finden Sie in Help Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by