Find Coefficient of a Trigonometric Function
7 views (last 30 days)
Show older comments
I would like to find the coeffienct of the trigonometric function by separated terms. How can I do that?
My codes are :
clear all;close all;clc;
syms h h1 h2 phi12 phi34 l1 l2 l3 l4 l5 l6 a b
x1=h/3-h1*cos(phi12)
y1=(l1^2-l2^2)/(2*a)
z1=h1*sin(phi12)
x2=(-1/2)*(h/3-h2*cos(phi34))-sqrt(3)/2*((l3^2-l4^2)/(2*a))
y2=(sqrt(3)/2)*(h/3-h2*cos(phi34))-1/2*((l3^2-l4^2)/(2*a))
z2=h2*sin(phi34)
P1P2=expand((x1-x2)^2+(y1-y2)^2+(z1-z2)^2-b^2)
[P1P2_c_cosphi34,P1P2_t_cos34]=coeffs(P1P2,cos(phi34)); C21=P1P2_c_cosphi34(2)
[P1P2_c_cosphi12,P1P2_t_cos12]=coeffs(P1P2,cos(phi12)); D21=P1P2_c_cosphi12(2)
I want to make the equation in this form of
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/851340/image.png)
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/851345/image.png)
Here I want to find the coefficient of A21, B21, C21, D21 and E21. How can I do this symbolically?
0 Comments
Answers (1)
VIGNESH B S
on 7 Jan 2022
syms x
f = 5.*x.^2 + 7.*x + 3
coeffs(f)
Use coeffs function.
Returns x^0 , x^1 .. ,x^n coeffs.
Also works with sin(x) , cos(x)..
See Also
Categories
Find more on Symbolic Math Toolbox in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!