UNIT-3_MATLAB PROGRAMMING_QUESTION BANK_SOLUTION (1)
UNIT-3_MATLAB PROGRAMMING_QUESTION BANK_SOLUTION (1)
function y = nestedFunction(x)
y = x^2;
end
end
Here, nestedFunction can only be called within mainFunction.
4. Calling Subfunctions
Subfunctions are additional functions defined within the same .m file as the main function but outside of
its main body. Subfunctions can only be called by the main function or other subfunctions within the
same file.
% Example: File "mainFunction.m"
function result = mainFunction()
result = helperFunction(5);
end