function [a b]=sample1(x) %Sample function to show that a function can be defined within a function. %This function calls sample2(x), defined within this page. a=sin(x); b=sample2(x); function b=sample2(x) b=cos(x);