i am trying to find coefficients a0 , an and bn but the output for bn seems wrong and will not simplify

2 Ansichten (letzte 30 Tage)
i am trying to find coefficients a0 , an and bn but the output for bn seems wrong and will not simplify
i have tried using pretty, symplify, ignoreanalyticconstraint,true and simplifyFraction, but none have worked
f(x) = -3, -pi < x < 0
f(x) = 3, 0 < x < pi
syms t n
T = 2*pi
w0 = 2*pi/T
n=1:5
a0 = (1/T)*int(3,t,-pi,0) + (1/T)*int(-3,t,0,pi)
an = (2/T)*int(-3*cos(n*w0*t),t,-pi,0) + (2/T)*int(3*cos(n*w0*t),t,0,pi)
bn = (2/T)*int(-3*sin(n*w0*t),t,-pi,0) + (2/T)*int(3*sin(n*w0*t),t,0,pi);
pretty(bn)
  1 Kommentar
VBBV
VBBV am 17 Jul. 2024
@scott lamb you can do double & vpa for the bn coefficient to simplify
syms t n
T = 2*pi;
w0 = 2*pi/T;
n=1:5;
a0 = (1/T)*int(3,t,-pi,0) + (1/T)*int(-3,t,0,pi);
an = (2/T)*int(-3*cos(n*w0*t),t,-pi,0) + (2/T)*int(3*cos(n*w0*t),t,0,pi);
bn = (2/T)*int(-3*sin(n*w0*t),t,-pi,0) + (2/T)*int(3*sin(n*w0*t),t,0,pi);
% double and vpa
double(vpa(bn))
ans = 1x5
3.8197 0 1.2732 0 0.7639
<mw-icon class=""></mw-icon>
<mw-icon class=""></mw-icon>

Melden Sie sich an, um zu kommentieren.

Antworten (1)

Matt J
Matt J am 1 Dez. 2020
Well, here is what I get for bn,
>> bn
bn =
[ 17202483417667977/4503599627370496, 0, 5734161139222659/4503599627370496, 0, 17202483417667977/22517998136852480]
You haven't told us whether you get the same thing, or if so what you would expect instead, but these terms do look nice when multiplied by pi,
>> double(bn*pi)
ans =
12.0000 0 4.0000 0 2.4000
  2 Kommentare
Walter Roberson
Walter Roberson am 1 Dez. 2020
syms t n
Pi = sym(pi);
T = 2*Pi;
w0 = 2*Pi/T;
n=1:5
n = 1×5
1 2 3 4 5
a0 = (1/T)*int(3,t,-Pi,0) + (1/T)*int(-3,t,0,Pi)
a0 = 
0
an = (2/T)*int(-3*cos(n*w0*t),t,-Pi,0) + (2/T)*int(3*cos(n*w0*t),t,0,Pi)
an = 
bn = (2/T)*int(-3*sin(n*w0*t),t,-Pi,0) + (2/T)*int(3*sin(n*w0*t),t,0,Pi);
pretty(bn)
/ 12 4 12 \ | --, 0, --, 0, ---- | \ pi pi 5 pi /

Melden Sie sich an, um zu kommentieren.

Kategorien

Mehr zu Symbolic Math Toolbox finden Sie in Help Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by