Extracting coefficients of 'sinwt', 'coswt', sin2wt etc from a symbiolic expression.

7 次查看(过去 30 天)
Hello,
I am having a mathmatical symbolic expression and want to extract the coefficient of 'sinwt', 'coswt', 'sin2wt' and so on.
For e.g. the expression is,
where, , and are symbolic variables. Now, is there anyway to get the coefficient of 'sinwt', 'coswt', 'cos3wt' etc. from this expression ? or in other words, is it possible to get the following desired output ?
  5 个评论

请先登录,再进行评论。

回答(1 个)

Gargi Patil
Gargi Patil 2021-8-12
Hi,
My understanding is that you would like to extract the coefficients of a symbolic trigonometric expression. The function "coeffs" can be used to return coefficients of an expression with respect to a specified term as follows:
syms a b c x
expr = a*sin(x)*b*sin(2*x) + c*sin(x);
[csin, tsin] = coeffs(expr, [sin(x), sin(2*x)])
csin = 
tsin = 

类别

Help CenterFile Exchange 中查找有关 Formula Manipulation and Simplification 的更多信息

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by