Question

ми М. -5 -4 -3 -2 -1 0 1 2 3 4 5 1

f) Calculate the coefficients of the trigonometric form of the Fourier series
numerically in MATLAB and graphically represent the one-sided spectrum
(width and phase) frequency for n up to 10 compared to the analytics results.
g) From the coefficients of the trigonometric form of the Fourier series ,
calculate the coefficients of the exposure series and present the two-sided spectrum (width and phase) frequency.
h) Find the average and active value of the signal from the Fourier expansion.
i) Check if the sum of the harmonics actually creates the original signal. To  verify this you need to add the fixed component and all the harmonious (for n = 1 to n = ). Since we can't do that in practice, try adding to MATLAB the first 5 harmonics in the constant component, then the constant component and the first 10 harmonics. Present graphically in the same chart the two last sums and the original signal .
0 0
Add a comment Improve this question Transcribed image text
Answer #1


Matlab code for Fourier Series clear all close all All time values X=linspace(-2,2,1001); Loop for creating the function for s=s+bb(i)*sin(i*pi*X/1)+aa (i)*cos(i*pi*X/1); plot(X,s) lgnd{i+1}=sprintf(Fourier %d terms.,i); end legend (lgnd, locationPlotting of Actual data Actual data Fourier 1 terms. Fourier 2 terms. Fourier 3 terms. Fourier 4 terms. Fourier 5 terms. -5 -

%Matlab code for Fourier Series
clear all
close all
%All time values
X=linspace(-2,2,1001);
%Loop for creating the function
for i=1:length(X)
    if X(i)>=-2 && X(i)<-1
        zz(i)=0;
    elseif X(i)>=-1 && X(i)<0
        zz(i)=-4.*X(i);
    elseif X(i)>=0 && X(i)<1
        zz(i)=4.*X(i);
    else
        zz(i)=0;
    end
end
figure(1)
%Plotting the function
hold on
plot(X,zz,'linewidth',3)
xlabel('x')
ylabel('f(x)')
title('Plotting of Actual data')
lgnd{1}='Actual data';


a1=X(1); b1=X(end);
l=(b1-a1)/2;
%Fourier series of the function for finding a and b coefficients
for j=1:20
    ss1=zz.*cos(j*pi*X/l);
    %all a values of the Fourier series
    aa(j)=(1/l)*trapz(X,ss1);
    ss2=zz.*sin(j*pi*X/l);
    %all b values of the Fourier series
    bb(j)=(1/l)*trapz(X,ss2);
end

%a0 value of Fourier series
aa0=(1/l)*trapz(X,zz);
X=linspace(-5,5,6001);
s=aa0/2;

%all an and bn terms
fprintf('Printing few terms for Fourier series\n')
for i=1:10
    fprintf('\tThe value of a%d=%f and b%d=%f. \n\n',i,aa(i),i,bb(i))
end
  
%Fourier series of the function
for i=1:5
    s=s+bb(i)*sin(i*pi*X/l)+aa(i)*cos(i*pi*X/l);
    plot(X,s)
    lgnd{i+1}=sprintf('Fourier %d terms.',i);  
end
legend(lgnd,'location','best')
box on
%%%%%%%%%%%%%%%%%% End of Code %%%%%%%%%%%%%%%%%
   

Add a comment
Know the answer?
Add Answer to:
f) Calculate the coefficients of the trigonometric form of the Fourier series numerically in MATLAB and...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT