plotting Fourier series periodic signal ?
10 次查看(过去 30 天)
显示 更早的评论
i have this homewrok which asked me to plot a fourier series
the issues:
- i don't know how to change it from unit step function
- i don't know how to plot it to the 2nd period
0 个评论
采纳的回答
Chandra
2022-5-2
编辑:Chandra
2022-5-4
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 个评论
Chandra
2022-5-4
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.
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Calculus 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!