All I need is part p I have an attempt clc syms n t this is
All I need is part p. I have an attempt.
clc;
syms n t
% this is the equation we\'re going to evaluate for Fourier.
x_t = (t/To)^2;
To = 2;
w0 = pi;
n = -3:3;
a0 = (2/To)*int(x_t, t, 0, 1)
an = (2/To)*int(x_t*cos(n*w0*t), t, 0, 1)
bn = (2/To)*int(x_t*sin(n*w0*t), t, 0, 1)
figure;
plot(an,\'*\')
title(\'an values\')
figure;
plot(bn,\'*\')
title(\'bn values\')
Solution
your code is correct sligth change i.e you wrote x_t before defining the T0
thats the problem
clc
clear all
syms n t
% this is the equation we\'re going to evaluate for Fourier.
To = 2;
w0 = pi;
n = -3:3;
x_t = (t/To)^2;
a0 = (2/To)*int(x_t, t, 0, 1)
an = (2/To)*int(x_t*cos(n*w0*t), t, 0, 1)
bn = (2/To)*int(x_t*sin(n*w0*t), t, 0, 1)
figure;
plot(an,\'*\')
title(\'an values\')
figure;
plot(bn,\'*\')
title(\'bn values\')
RESULT:
a0 =
1/12
an =
[ -1/(18*pi^2), 1/(8*pi^2), -1/(2*pi^2), 1/12, -1/(2*pi^2), 1/(8*pi^2), -1/(18*pi^2)]
bn =
[ -(9*pi^2 - 4)/(108*pi^3), 1/(8*pi), -(pi^2 - 4)/(4*pi^3), 0, (pi^2 - 4)/(4*pi^3), -1/(8*pi), (9*pi^2 - 4)/(108*pi^3)]

