aprsc7

Full sine wave fourier

Nov 2nd, 2020 (edited)
2,006
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
MatLab 0.61 KB | None | 0 0
  1. % full rectified sine wave
  2. clear
  3. clc
  4. k_max = input('Enter>>');
  5. num_kmax = length(k_max);
  6. for z = 1:num_kmax
  7.     k = [-k_max(z):k_max(z)];
  8.     L_k = length(k);
  9.     a_k = zeros(1, L_k); % Form vector of Fourierseries coefficients,
  10.    
  11.     for i=1:2:L_k % as a zero array and then
  12.         a_k(i)=2/(pi*(1-k(i)^2)); % fill in nonzero values
  13.     end
  14.    
  15.     omega_0 = 2*pi;
  16.     t = 0:.005:3;
  17.     x = a_k*exp(j*omega_0*k'*t);
  18.    
  19.     subplot(num_kmax,1,z),plot(t,real(x)), ylabel('partialsum'),...
  20.     axis([0 3 -0.5 1.2]), text(.05,-.25,['max. har. =',num2str(k_max(z))]),...
  21.     text(2.0,-.25,['Name / Matric No']),
  22. end
  23. xlabel('t');
  24.  
Add Comment
Please, Sign In to add comment