plotting Fourier series periodic signal ?
조회 수: 2 (최근 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
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/981605/image.png)
댓글 수: 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에서 Spectral Measurements에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!