Expressions with variables

>> clear x >> exp(-x)+sin(x)

??? Undefined function or variable 'x'.The `value' given to a variable does not need to be a numerical value. For example, the `value' of a variable could also be a `string'. This is an expression between quotes ('). In fact, we have already been using this with

`ezplot`

, `fzero`

en `fminbnd`

. Consider the result of
>> f='exp(-x)+sin(x)' f = exp(-x)+sin(x) >> ezplot(f,[0 2*pi])The variable

The function

>> fzero(f,[3,4]) Zero found in the interval: [3, 4]. ans = 3.1831 >> fminbnd(f,4,5) ans = 4.7213These commands do not give an error message, because of the fact that by specifying the search interval we have temporarily given

>> x = sym('x') x = xor

>> syms xwhich gives the same result. You can give a symbolic value to more than one variable at the same time in the following way:

syms x y zYou can now manipulate with these variables to your heart's desire.

>> v = x^3 + y^2 + 1 v= x^3+y^2+1 >> w = sin(z) w = sin(z) >> v*w ans = (x^3+y^2+1)*sin(z)

Esteur 2010-03-22