MATLAB: Get coeffs of exponents

differential equationsmatrix

How can I get the coeffs of exponents?
for example:
A=-1*exp(t*w*-1i)/2 + exp(t*w*1i)/2 – exp(t*w*2i)/2 + exp(t*w*-2i)/2
I want to get: [-0.5, 0.5, -0.5, 0.5]

Best Answer

Hi,
You can use syms and coeffs.
Example:
syms t w i
A=-1*exp(t*w*-1i)/2 + exp(t*w*1i)/2 - exp(t*w*2i)/2 + exp(t*w*-2i)/2
coeffs(A)
Hope it helps.