Example of symbolic operations on Matlab
>> syms a x
>> y = a*sin(x)+2*sin(x)^2;
>> diff(y)
differentiation of y
ans = a*cos(x)+4*sin(x)*cos(x)
>> diff(ans)
ans = -a*sin(x)+4*cos(x)^2-4*sin(x)^2
>> int(ans)
integration of ans
ans = a*cos(x)+4*sin(x)*cos(x)
>> int(ans)
ans = a*sin(x)+2*sin(x)^2
>> syms x y
>> z = sin(x)+cos(y)
z = sin(x)+cos(y)
>> x = pi/2;
y = pi/2;
>> z
z = sin(x)+cos(y) here you can see that x and y variables
values are not considered while computing z.
No comments:
Post a Comment