Question

(a) Find the Fourier series for 25 { O if 1 r<O 1-2 if 0<H<1 f(x) defined on the interval -1<rs1. T-2 (b) Using MATLAB, plot

0 0
Add a comment Improve this question Transcribed image text
Answer #1

Fowrien Series o *くみく0 ○くnく1 2 -2 Forr periodic fmetien ) ith p2sics d Fowie eTaes ^cu) (T 0- Tuo Com cNJi Hem aM an Con a o

2 Con So that 2 Con C Bn - -Cen (na) bn -Matlab code for Fourier Series clear all close all &All time values Xlinspace(-1,1,1001) creating the function for Xi X(i)<0ylabelf(t) ) titleFourier series of given function for 20 terms ) elseif i--200 figure (3) plot (X,s) XLabel time) i+eFouriPlotting of Actual data 0.9 0.8 0.7 0.6 0.5 0 4 03 02 0.1 n6 0.8 02 -0.4 0.6 08 given function for 20 terms Fourier series n8Fourier series of given function for 200 terms 1 2 0.8 F 0.6 0.4 02 time Published with MATLAB® R201 8a 4

%Matlab code for Fourier Series
clear all
close all
%All time values
X=linspace(-1,1,1001);
%Loop for creating the function
for i=1:length(X)
    if X(i)>=-1 && X(i)<0
        zz(i)=0;
    else
        zz(i)=1-(X(i)).^2;
    end
end
figure(1)
%Plotting the function
plot(X,zz)
xlabel('x')
ylabel('f(x)')
title('Plotting of 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:200
    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(-3,3,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:200
  
    s=s+bb(i)*sin(i*pi*X/l)+aa(i)*cos(i*pi*X/l);
    if i==20
        figure(2)
        plot(X,s)
        xlabel('time')
        ylabel('f(t)')
        title('Fourier series of given function for 20 terms')
      
      
    elseif i==200
        figure(3)
        plot(X,s)
        xlabel('time')
        ylabel('f(t)')
        title('Fourier series of given function for 200 terms')
      
    end
      
end


%%%%%%%%%%%%%%%%%% End of Code %%%%%%%%%%%%%%%%%
   

Add a comment
Know the answer?
Add Answer to:
(a) Find the Fourier series for 25 { O if 1 r<O 1-2 if 0<H<1 f(x) defined on the interval -1<rs1. T-2 (b) U...
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