To create a new function called "function_name", open a new m-file by selecting from the menu buttons:
Type in the definition of the function with statements such as:
function y=function_name(x)
y= 2*x.^3+ 3*x.^2 +4*log(x)-exp(x);
Then save the file as an m-file in the work subdirectory as:
function_name.m
It must be saved as the same name that appears in the function statement in order to avoid confusion.
To see the value of the function for a given value of x, say x=5, simply type
in the command window:
To see multiple values of the function for multiple values of x, say x=1:10, simply type
in the command window:
To plot the function between limits, say, x=1 and x=8, simply type
in the command window: