Wednesday, 25 September 2013

MATLAB symbolic tool box

I find the symbolic tool box in MATLAB to be very useful. It is possible to do symbolic integration, differentiation, solving equations, simplifying symbolic formulae, etc.


In order to use symbolic functions in this tool box, we should first define symbolic variables. Symbolic variables a, b and c  can be defined as;


syms a, b, c;

Then we define a symbolic function as

f = a^2 + 2b +c;

The above function f, can be passed to symbolic tool box functions such as diff() or int(), to differentiate or integrate, respectively.

For example, function diff() takes two parameters, first the function to differentiate and second the variable with respect to which the function is differentiated. Thus,

diff(f, a) = 2a;
diff(f, b) = 2;
diff(f, c) = 1;

Similarly int() function gives the symbolic integration of a function with respect to thr specified symbolic variable.

simple() is another function that is very handy and I use quite often. simple(f), as its name says, simplifies function f. Another cool function in this tool box is pretty()! pretty(f) formats the way function f is displayed, such that it is more readable and pretty!

No comments:

Post a Comment