What is going on here is that the x in f gets replaced by whatever the argument to the function is. There are a few ways to convert f to a function. We can evaluate f(4) by substituting 4 for x, or in other words, by typing subs(f,x,4) In the case of several symbolic variables, we can specify the one with respect to which we want to differentiate.
Notice that MATLAB recognizes what the "variable" is. The next lines will show that we can differentiate f, but we cannot evaluate it, at least in the obvious way, since f(4) will give an error message (try it!).
This definition is more general for example, it allows us to define a function f(x) to be x^2 in case x is negative or 0, and sin(x) in case x is positive. The other is a rule (algorithm) for producing a numerical output from a given numerical input or set of numerical inputs. One is a symbolic expression such as sin(x) or x^2. There are two distinct but related notions of function that are important in Calculus. Later, we will need to discuss MATLAB's routines for dealing with functions of several variables. For the present, we will confine ourselves to functions of one variable. We will try to provide concrete illustrations of each of the concepts involved as we go along. These fall into three broad categories: symbolic computation, numerical computation, and plotting, and we will deal with each of them in turn. We will discuss first the representation of functions and then the ways of accomplishing the things we want to do with them. The central concept is that of a function. In this published M-file we will try to present some of the central ideas involved in doing calculus with MATLAB.