Symbolic calculation using Matlab

The thing is that some times running a simulation over and over again makes no sense. One have to see the mathematical formula that is being computed to make some safe assumptions and change his approach on a subject. Without getting in detail on where someone could use something like this, Matlab gives the possibility of symbolic calculation. That is, if I want to see how the output of function call_func affects the inputs A and B (for a really long list of reasons) I can use syms.

Thus the code:

 
syms A B
result = call_func(A,B);

The above code stores in result what would be the result but with A and B kept as symbols. So if function call_func computes the A^2 + 2*A*B + B^2 (that seems familiar…) we get:

result =
A^2 + 2*A*B + B^2

Which is pretty straightforward but I could not come up with something more practical. I use the syms command lately to observe the impact of each coefficient in an FFT. Also I used in before to get the result of the multiplication between two large matrices so that I could use it as a formula instead.

Advertisements