I have two functions:
function [] = func_one()
S.pb = uicontrol('style','push','unit','pix','posit',[20 20 260 30],
'string','Print Choices','callback',{@func_two,S});
and I have the second function:
function [a] = func_two(varargin)
a = 'alon';
end
I want func_one to return the variable a of func_two. How can I do that please?
I tried:
function [a] = func_one()
But I guess I have to do something with ‘callback’,{@func_two,S})
Thank you all!
If, as you say, you want
func_oneto return the valueainfunc_twothen the easiest way to do this without using a callback is:The above will allow you to say run
a=func_oneandawill be the string'alon'.If you really really want
func_two()to be a callback of your pushbutton, and you wanta='alon'to be assigned in the workspace offunc_one(the function that callsfunc_two) then put this infunc_twoAnd if neither is what you want, then maybe you can indicate why you want
func_oneto return whatfunc_tworeturns – like the exact interaction you are hoping to have with your GUI and how it differs from what you’re actually experiencing.