Unit-3 - Matlab Programming - Question Bank - Solution
Unit-3 - Matlab Programming - Question Bank - Solution
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