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
  • MATLAB code starts here --------- clear T0=2; w0=2*pi/T0; f0=1/T0; Tmax=4; Nmax=15; %--- i=1; for t=-Tmax: .01:Tmax...

    MATLAB code starts here --------- clear T0=2; w0=2*pi/T0; f0=1/T0; Tmax=4; Nmax=15; %--- i=1; for t=-Tmax: .01:Tmax T(i)=t; if t>=(T0/2) while (t>T0/2) t=t-T0; end elseif t<=-(T0/2) while (t<=-T0/2) t=t+T0; end end if abs(t)<=(T0/4) y(i)=1; else y(i)=0; end i=i+1; end plot(T,y),grid, xlabel('Time (sec)'); title('y(t) square wave'); shg disp('Hit return..'); pause %--- a0=1/2; F(1)=0; %dc freq C(1)=a0; for n=1:Nmax a(n)=(2/(n*pi))*sin((n*pi)/2); b(n)=0; C(n+1)=sqrt(a(n)^2+b(n)^2); F(n+1)=n*f0; end stem(F,abs,(C)), grid, title(['Line Spectrum: Harmonics = ' num2str(Nmax)]); xlabel('Freq(Hz)'), ylabel('Cn'), shg disp('Hit return...'); pause %--- yest=a0*ones(1,length(T)); for n=1:Nmax yest=yest+a(n)*cos(2*n*pi*T/T0)+b(n)*sin(2*n*pi*T/T0);...

  • Also : FS (2.8) FS (4) FS (5) The function f(t) is defined by -3t+6, 0<t<4...

    Also : FS (2.8) FS (4) FS (5) The function f(t) is defined by -3t+6, 0<t<4 f(t) = -3, 4 < t < 5. Let f (t) denote the periodic extension of f(t), with period 5. Evaluate f (-2.3), f (O), f (7.5), f (9.2) and state the value to which the Fourier series of f (t), FS(t), converges for each of the following values: t = 0,t = 2.8, t = 4, t = 5. Enter all your answers...

  • Q#4: (24 points) Given the function y-f(x) shown below: na f(r) -3 (a) Calculate the period of fu...

    Q#4: (24 points) Given the function y-f(x) shown below: na f(r) -3 (a) Calculate the period of function, T and frequency, (2TT)/T (b) Calculate the Fourier Coefficients Ao. An, and Bn of the Fourier series expansion of function, y-f(x). Here n 1, 2, 3,... (integers) (c) Write the Fourier series approximation of function, yf(x), in terms of numbers, n & x only Q#4: (24 points) Given the function y-f(x) shown below: na f(r) -3 (a) Calculate the period of function,...

  • Create a file named “toneA.m” with the following MATLAB code: clear all Fs=5000; Ts=1/Fs; t=[0:Ts:0.4]; F_A=440;...

    Create a file named “toneA.m” with the following MATLAB code: clear all Fs=5000; Ts=1/Fs; t=[0:Ts:0.4]; F_A=440; %Frequency of note A is 440 Hz A=sin(2*pi*F_A*t); sound(A,Fs); Type toneA at the command line and then answer the following: (a) What is the time duration of A? (b) How many elements are there in A? (c) Modify toneA.m by changing “Fs=5000” to “Fs=10000”. Can you hear any difference? (d) Create a file named “tone.m” with the following MATLAB code: function x = tone(frequency,...

  • Please answer "b" only. %Example code function plotFS(m); %m = user provided number of terms desired in the Fou...

    Please answer "b" only. %Example code function plotFS(m); %m = user provided number of terms desired in the Fourier series; %this code computes the Fourier series of the function %f(x)=0, for -pi<= x <0, % =cos(x) for 0<= x <pi %generate the interval from -pi to pi with step size h; h = pi/100; xx1=[-pi:h:0]; xx2=[0:h:pi]; xx = [xx1, xx2]; %generate the given function f so that it can be graphed ff = [zeros(size(xx1)), cos(xx2)]; %compute the first partial sum...

  • Calculate the Fourier Series coefficients of x(t) = cos(2*pi*1*t) + 2*sin(2*pi*4*t). Based on your results which...

    Calculate the Fourier Series coefficients of x(t) = cos(2*pi*1*t) + 2*sin(2*pi*4*t). Based on your results which set of FS coefficients corresponding to the positive side of the spectra is correct.    a0=0, a1=1/2, a2=1/j, a3 = 0     a1=1, a2=2, a3 = 0     a1=1/2j, a2=1/2, a3 = 0     a1=1/2, a2=2/2j, a3 = 0

  • 3. Consider the function defined by f(x) = 1, 0 < r< a, | 0, a<...

    3. Consider the function defined by f(x) = 1, 0 < r< a, | 0, a< x < T, where 0a < T (a) Sketch the odd and even periodic extension of f (x) on the interval -3n < x < 3« for aT/2 (b) Find the half-range Fourier sine series expansion of f(x) for arbitrary a. (e) To what value does the half-range Fourier sine series expansion converge at r a? [8 marks 3. Consider the function defined by...

  • (4) Consider the function f(0) = 10 € C(T). (a) Show that the Fourier coefficients of...

    (4) Consider the function f(0) = 10 € C(T). (a) Show that the Fourier coefficients of f are if n = 0, f(n) (-1)" - 1 if n +0. l n2 (b) Justify why the Fourier series of f converges to f uniformly on T. (c) Taking 0 = 0 in the Fourier series expansion of f, conclude that HINT: First prove that n even

  • Can you please help me answer Task 2.b? Please show all work. fs=44100; no_pts=8192; t=([0:no_pts-1]')/fs; y1=sin(2...

    Can you please help me answer Task 2.b? Please show all work. fs=44100; no_pts=8192; t=([0:no_pts-1]')/fs; y1=sin(2*pi*1000*t); figure; plot(t,y1); xlabel('t (second)') ylabel('y(t)') axis([0,.004,-1.2,1.2]) % constrain axis so you can actually see the wave sound(y1,fs); % play sound using windows driver. %% % Check the frequency domain signal. fr is the frequency vector and f1 is the magnitude of F{y1}. fr=([0:no_pts-1]')/no_pts*fs; %in Hz fr=fr(1:no_pts/2); % single-sided spectrum f1=abs(fft(y1)); % compute fft f1=f1(1:no_pts/2)/fs; %% % F is the continuous time Fourier. (See derivation...

  • Rewrite the following for loop into a whileloop. 1 2 3 4 int s = 0;...

    Rewrite the following for loop into a whileloop. 1 2 3 4 int s = 0; for (int i = 1; i <= 10; i++) {    s = s + i; } Given variables int n and double pi, write a snippet of code that assigns to pi the approximation of π resulting from adding the first nterms in the Gregory-Leibniz series: Given variables int areaBound and int sum, write a snippet of code that assigns to sum the result...

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