Advertisement
Guest User

Untitled

a guest
Oct 22nd, 2014
119
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.92 KB | None | 0 0
  1. function srec = Fourierreconstruct(T,ca,cb,Krec,Nrec)
  2. % srec =Fourierreconstruct(a,b,Krec,Nrec) reconstructs the signal by
  3. % Fourier series expansion
  4. % Input paramters:
  5. % a,b the arrays of the coefficients as calculated in Q2
  6. % Krec The number of points on which the reconstructed signal is sampled
  7. % Nrec the number of coefficients that is going to be used
  8. % Ouptut variables:
  9. % srec The samples of the signal
  10.  
  11. srec=zeros(1,Krec); % allocate memory for the samples
  12. delta=T/Krec; % calculate delta
  13. time=zeros(1,Krec); % allocate memory for the time
  14.  
  15. for k=1:Krec
  16. srec(k)=0; % calculate a0
  17. time(k)=delta*k; % calculate the time
  18. for n=0:Nrec-1 % calculate the signal by summing the sines and cosines
  19. srec(k)=srec(k)+(ca(n+1)*cos((2*pi*n*k)/Krec))+(cb(n+1)*sin((2*pi*n*k)/Krec));
  20. end
  21. end
  22. figure(2);
  23. plot(time,srec); % plot the reconstructed signal
  24. xlabel('time (s)');
  25. ylabel('signal (V)');
  26. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement