Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function srec = Fourierreconstruct(T,ca,cb,Krec,Nrec)
- % srec =Fourierreconstruct(a,b,Krec,Nrec) reconstructs the signal by
- % Fourier series expansion
- % Input paramters:
- % a,b the arrays of the coefficients as calculated in Q2
- % Krec The number of points on which the reconstructed signal is sampled
- % Nrec the number of coefficients that is going to be used
- % Ouptut variables:
- % srec The samples of the signal
- srec=zeros(1,Krec); % allocate memory for the samples
- delta=T/Krec; % calculate delta
- time=zeros(1,Krec); % allocate memory for the time
- for k=1:Krec
- srec(k)=0; % calculate a0
- time(k)=delta*k; % calculate the time
- for n=0:Nrec-1 % calculate the signal by summing the sines and cosines
- srec(k)=srec(k)+(ca(n+1)*cos((2*pi*n*k)/Krec))+(cb(n+1)*sin((2*pi*n*k)/Krec));
- end
- end
- figure(2);
- plot(time,srec); % plot the reconstructed signal
- xlabel('time (s)');
- ylabel('signal (V)');
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement