Question

I have a function Func.m which I want to pass a parameter to it using GUI in Matlab. The GUI will has a text_box and a button, where the text inside the textbox will be passed to function Func.m when the button is pressed. So if anyone could please advise as this is my first time to use Matlab GUI

Was it helpful?

Solution

You can get the string from the button in your GUI using the following command.

buttonString = get(handles.ButtonName,'String') 

You can then just call your function the same way you would any other function. Just make sure the function, if in a separate file, is in the same directory as your GUI *.m file, or just add whatever directory it is in to your path.

returnVal = someFunction(buttonString);
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top