Is there a way to define a general function in matlab?

Matlab has functionalities that allow you to work with known functions that you must define.

But, sometimes I want to do a complex symbolic calculation using a general function, Say A(x), without specifying A(x).

In other words, is it possible for me to make a statement like

diff(A(x^2+1),x), where the answer should involve a symbolic derivative of A??? diff(A(x^2+1),x) = A' diff(x^2+1,x)

That is, if A' is the derivative of A.

Upvotes: 2

Views: 81

Answers (1)

Landak
Landak

Reputation: 904

Yes. The functionality you describe is part of the symbolic algebra toolkit -- note that it comes with some fairly significant limitations, but, in short, all you would require would be

syms x A(x) 
diff(A(x), x)

Note that ' is reserved for transpose, even with symbolic functions. (Although, personally, I'd frankly suggest Mathematica for any serious symbolic algebra any day over matlab -- it's really the intended purpose of the whole product, whereas the symbolic algebra toolkit is exactly that: a toolkit add-on to the core features of Matlab, namely fast linear algebra).

Upvotes: 3

Related Questions