MATLAB: Output of symoblic expression coming out incorrectly

equationsymbolic

Hi guys,
I am using the code pasted below with the corresponding output:
syms X w t p
eq = X*cos(w*t – p)
eq =
X*cos(p – t*w)
The output is is reversed it should instead be X*cos(w*t – p). How would I change this?

Best Answer

The two expressions are identically equal for the cosine function, just as t*w and w*t are identically equal because of the commutative law of multiplication. The symbolic toolbox has a tendency to rearrange expressions in accordance with some criteria unknown to us mere mortals, provided the result is still identically equal.
Related Question