Monday, April 16, 2012

Calculate value of symbolic equation in MATLAB

I have following MATLAB code:



>> syms x
>> z = 20.*exp(x)+cos(x)
>> derivative = diff(z)


How can I calculate value of derevative for any number, e.g. 6?



Following commands



>> clear all
>> x = 6
>> derevative = 20*exp(x)-sin(x)


works fine, but if x is symbolic I don't use x = 6 such as above example.





No comments:

Post a Comment