Can you make a section of a GUI jump back to another?

1 view (last 30 days)
I'm currently making a GUI that essentially filters data based on different parameters and then graphs the answer.
This group of radio buttons changes the filtering parameters and thus changes the answer you get.
I was wondering if you can use the MATLAB GUI syntax to help aid in this process. Here's the code for the radiobutton callback. I want it to automatically branch back to the filter function part of the GUI without having the copy and paste the code again that makes it display. Is there any function/command that will essentially say "go back to this part of the GUI code"?
% --- Executes when selected object is changed in waveselection.
function waveselection_SelectionChangedFcn(hObject, eventdata, handles)
% hObject handle to the selected object in waveselection
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% Changes the
switch(get(eventdata.NewValue,'Tag'));
case 'deltawave'
handles.filterFreqs = [1 5];
case 'alphawave'
handles.filterFreqs = [7 16];
case 'betawave'
handles.filterFreqs = [14 41];
case 'gammawave'
handles.filterFreqs = [29 101];
end
guidata(hObject, handles);%Updates handles structure
Thank you greatly for any and all help!

Accepted Answer

Walter Roberson
Walter Roberson on 21 Apr 2019
Edited: Walter Roberson on 21 Apr 2019
Create a function that does the functionality you want to "branch back to". Call that function from both callbacks. No duplicated code, just two places that call the same code.
  1 Comment
Blair Armstrong
Blair Armstrong on 21 Apr 2019
Okay that makes sense, any exceptionally weird syntax when calling a function inside a GUI instead of just 'regular' code? Or just the usual stuff (i.e. making sure its in the same directory)?

Sign in to comment.

More Answers (0)

Categories

Find more on Specifying Target for Graphics Output in Help Center and File Exchange

Products


Release

R2018a

Community Treasure Hunt

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

Start Hunting!