Question

You are given a finite step function xt=-1  0<t<4 1  4<t<8.           Hand calculate the FS coefficients of...

  1. You are given a finite step function xt=-1  0<t<4
  2. 1  4<t<8.

         

  1. Hand calculate the FS coefficients of x(t) by assuming half- range expansion, for each case below.
  2. Modify the code below to approximate x(t) by cosine series only (This is even-half range expansion). Modify the below code and plot the approximation showing its steps changing by included number of FS terms in the approximation.
  3. Modify the code below to approximate x(t) by sine series only (This is odd-half range expansion).. Modify the below code and plot the approximation showing its steps changing by included number of FS terms in the approximation.

MATLAB CODE

_____________________________________________________________________________________________________________________________________________________________________

clear all

close all

% Example MATLAB M-file that plots a Fourier series

% Set up some input values

P = 4; %period = 2P

num_terms = 100; %approximate infinite series with finite number of terms

% Miscellaneous setup stuff

format compact; % Gets rid of extra lines in output. Optional.

% Initialize x-axis values from -1.25L to 1.25L. Middle number is step size. Make

% middle number smaller for smoother plots

t = -4:0.001:4;

x=zeros(length(t),1);   % reseting original half range expanded function array

x(0<=t & t<2)=1;       % forming the original half range expanded function array for the purpose of plotting only

x(2<t & t <4)=0;

x(t<0 & -2<t)=1;

x(t<-2 & t>-4)=0;

figure     %plotting original half range expanded function

plot(t,x)

axis([-4.5 4.5 -0.5 1.5])

%Starting to approximate f(t)

% Initialize y-axis values. y = f(t)

f = zeros(size(x'));

% Add a0/2 to series

a0 = 1;

f = f + a0/2;

% Loop num_terms times through Fourier series, accumulating in f.

figure

for n = 1:num_terms

   

   

    % Formula for an.

    an = (2/(n*pi))*sin(n*pi/2);

        bn=0;

   

    % Add cosine and sine into f

    f = f + an*cos(n*pi*t/P) + bn*sin(n*pi*t/P);

   

    % Plot intermediate f. You can comment these three lines out for faster

    % execution speed. The function pause(n) will pause for about n

    % seconds. You can raise or lower for faster plots.

    plot(t,f);

    set(gca,'FontSize',16);

    title(['Number of terms = ',num2str(n)]);

    grid on;

    if n < 5

        pause(0.15);

    else

        pause(0.1);

    end

    xlabel('even approx');

end;

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

SOLUTION

In mathematics, a function on the real numbers is called astep function(or staircase function) if it can be written as afinite linear combination of indicator functions of intervals. Informally speaking, a step function is a piecewise constantfunction having only finitely many pieces.

Add a comment
Know the answer?
Add Answer to:
You are given a finite step function xt=-1  0<t<4 1  4<t<8.           Hand calculate the FS coefficients of...
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