%% Using an external function % Assuming you defined the function f, or it is a built in function % call a function f and evaluate f(2). x = 2; f(x) %% Using an inline function % Define a function g and evaluate g(3). g = inline('x^2+2*x+2'); g(3) %% Using a symbolic function % Define a symbolic function h and evaluate h(4). x = 4; h = 'x^3+3*x-5'; eval(h) %% Using a function handle % Define a function i to be f and evaluate i(5) and i(6). i = @f; i(5) feval(i,6) %% Error messages % The function j was defined, j(x) = x unless x = 0 in which case it stops % with an error message. j(1) j(0) j(3)