MATLAB: Is it possible to create multiple functions and calling them in one .m file

callgui

I have a question about calling a function in Gui. Here is an example of my code:
function pushbutton1_Callback(hObject, eventdata, handles)
ABC = handles.Murthy(result); %%????? This line
%button implementation
function maxmax = Murthy (result)
%Murthy implementation
The function Murthy also contains "axes(handles.axes1);" etc. How to call function Murthy without deleting gui control codes (like "axes(handles.axes1)" etc) from it? Thanks in advance!

Best Answer

Generically, this is the process:
function whee = whatevs(a,b,c) %1st line of m file
whee = alpha(a) + beta(b) + gamma(c);
end
function a = alpha(x) %still in the whatevs.m



a = x.^2;
end
function b = beta(x) %still in the whatevs.m
b = 2.^x;
end
function c = gamma(x) %still in the whatevs.m
c = x^x;
end
You can also "nest" functions: eg, gamma could be:
function c = gamma(x) %still in the whatevs.m
c = banana^x;
function b = banana
b = randn*5;
end
end