![]() ![]() Here is the matlab code: clear all clc syms x pi3. T = 0.0:5.0e-5:4.0e-3 % it's already given in text (0 to 4ms with interval of 0. First of all, find the coefficients of fourier series ao,an,bn. % Now, we have a row vector " a2" with total values " 81" į1 = a2' % Here, we have final values " f1" (total 81 points) as transpose of a2 computed above S1(n,m) = (4/pi)*(1/(2*n - 1))*sin((2*n - 1)*2*pi*f*dt*(m-1)) % Approximate Fourier Series g(t)Ī1 = s1(:,m) % VERY IMPORTANT ! Here, we are assigning a1 for each single column (total 81)Ī2(m) = sum(a1) % Here, we are summing up the whole column to one single value (adding all 12 values in one column) Tpts = (4.0e-3/5.0e-5) + 1 % Total points " (final point-initial point)/Interval+1%įor n = 1: 12 % Values we are considering to approximate Fourier Seires instead of infinity as given in original function x(t)įor m = 1: tpts % Here, we'll consider all " t" points to cover " from 0 to 4ms interval" % Fourier Series Expansion for Square Waveĭt = 5.0e-05 % Interval between teo time steps Now, we will write a Matlab code for g(t) between 0 and 4ms with an interval of 0.05 ms to demonstrate that g(t) is a decent approximation of original function x(t). ![]() Let’s assume we have a square wave with following characteristics:
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |