Find Coefficient of a Trigonometric Function

3 Ansichten (letzte 30 Tage)
ercan duzgun
ercan duzgun am 3 Jan. 2022
Kommentiert: ercan duzgun am 7 Jan. 2022
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
Here I want to find the coefficient of A21, B21, C21, D21 and E21. How can I do this symbolically?

Antworten (1)

VIGNESH B S
VIGNESH B S am 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)..
  1 Kommentar
ercan duzgun
ercan duzgun am 7 Jan. 2022
Dear @VIGNESH B S thanks for your answer.
I used that function of coeffs. It is in my code , as you can see. However it only find some of the coefficients in my program. I can only find C21 and D21 coefficient. I can't find other coefficient of A21 B21 E21.

Melden Sie sich an, um zu kommentieren.

Produkte


Version

R2019b

Community Treasure Hunt

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

Start Hunting!

Translated by