plotting Fourier series periodic signal ?

9 Ansichten (letzte 30 Tage)
Faisal Al-Wazir
Faisal Al-Wazir am 28 Apr. 2022
i have this homewrok which asked me to plot a fourier series
the issues:
  1. i don't know how to change it from unit step function
  2. i don't know how to plot it to the 2nd period

Akzeptierte Antwort

Chandra
Chandra am 2 Mai 2022
Bearbeitet: Chandra am 4 Mai 2022
Hi,
For plotting x(t) use stem function
T1 = 2;
T0 = 8;
x1 = ones(1,2*T1); % 1 i.e., 0<t<T1
x2 = -1*ones(1,T0/2-T1); %-1 i.e., T1<t<T0/2
x = [x2 x1 x2];
%x = [x x x];
%t = linspace(-12,12,length(x));
t = linspace(-4,4,length(x)); %comment this line if 6 and 7 lines are uncommented
stem(t,x);
axis([-15 15,-2 2]);
for fourier series of x, refer to this link
  7 Kommentare
Chandra
Chandra am 4 Mai 2022
Hi,
Use the code below for output values with different harmonics
clc
clear all
syms n t
T = 8;
w = 2*pi/T;
% Exponential Fourier series
C(n) = (1/T)*(int(1*exp(-1i*w*n*t),t,0,2)+int(-1*exp(-1i*w*n*t),t,2,6)+int(1*exp(-1i*w*n*t),t,6,8));
C0 = limit(C(n),n,0); % C(0)
Harmonics = [C0 C(1) C(2) C(3) C(4) C(5) C(6) C(7) C(8) C(9) C(10) C(11) C(12) C(13) C(14) C(15) C(16) C(17) C(18) C(19) C(20) C(21) C(22) C(23) C(24) C(25) C(26) C(27) C(28) C(29) C(30) C(31) C(32)];
fprintf('First 13 Harmonics:\n')
Harmonics = Harmonics*2; %an = cn *2
disp(Harmonics)
% f(t) using Fourier Series representation
L = 4; % change values accordingly to 8, 16 32
f(t) = symsum(C(n)*exp(1i*w*n*t),n,-L,-1)+C0+symsum(C(n)*exp(1i*w*n*t),n,1,L);
fplot(t,f(t))
xlabel('t')
ylabel('f(t)')
title('f(t) using Fourier Series Coefficients')
grid on
Change the L value accordingly as 4 , 8 , 16 , 32 ,etc..
frequency of a16 is 16*(1/8) = 2KHz.
Faisal Al-Wazir
Faisal Al-Wazir am 4 Mai 2022
Thanks chandra

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (0)

Community Treasure Hunt

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

Start Hunting!

Translated by