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 %note this is the first column of a larger matrix used to store each %subsequent partial sum ps(1,:) = .5*cos(xx); % %compute the next partial sum using Matlab's symbolic integrator syms x %declare the symbolic variable, used in the int command below ps(2,:) = ps(1,:) + sin(2*xx)*int(cos(x)*sin(2*x), 0, pi)/pi; %note that many of the coef are zero so are not included nor computed for n = 4:2:m temp = int(cos(x)*sin(n*x), 0, pi)/pi;%integrate this directly ps(n,:) = ps(n-2,:) + temp*sin(n*xx); %plot(xx,ps(n,:),'k-'); hold on; %plot intermediate partial sums as %they're generated end figure(1); %plot the original given function, over three period plot(xx,ff,'k-', xx+2*pi*ones(size(xx)),ff,'k-',xx-2*pi*ones(size(xx)),ff,'k-'); hold on; %plot the m-th partial sum plot(xx,ps(m,:),'b-'); %extend the graph over two more periods plot(xx,ps(m,:),'b-', xx+2*pi*ones(size(xx)),ps(m,:),'b-', xx-2*pi*ones(size(xx)),ps(m,:),'b-'); legend('Original Fc', 'm-th Partial Sum'); title('Function and its Fourier series'); return %anything written after "return" will not be executed...
%Matlab code for Fourier Series
clear all
close all
%All time values
t=linspace(-pi,pi,1001);
%Loop for creating the function
for i=1:length(t)
if t(i)>=-pi && t(i)<0
zz(i)=0;
else
zz(i)=sin(t(i));
end
end
figure(1)
%Plotting the function
plot(t,zz,'Linewidth',2)
xlabel('t')
ylabel('f(t)')
title('Plotting of Actual data and Fourier sum')
a1=t(1); b1=t(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*t/l);
%all a values of the Fourier series
aa(j)=(1/l)*trapz(t,ss1);
ss2=zz.*sin(j*pi*t/l);
%all b values of the Fourier series
bb(j)=(1/l)*trapz(t,ss2);
end
%a0 value of Fourier series
aa0=(1/l)*trapz(t,zz);
t=linspace(-pi,pi,6001);
s=aa0/2;
fprintf('Yes this function is continuous and
differentiable.\n\n')
%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
lgnd{1}='Actual plot';
%Fourier series of the function
hold on
for i=1:10
s=s+bb(i)*sin(i*pi*t/l)+aa(i)*cos(i*pi*t/l);
plot(t,s)
lgnd{i+1}=sprintf('Fourier sum for %d
terms',i);
end
legend(lgnd,'Location','northwest')
%%%%%%%%%%%%%%%%%% End of Code %%%%%%%%%%%%%%%%%
Please answer "b" only. %Example code function plotFS(m); %m = user provided number of terms desired in the Fou...
Consider the function f defined on the interval-5, 5 as follows, { E5,0), те (0,5). 3. f(x) = 3. Denote by fr the Fourier series expansion of fon [-5,5]. fF(x)= 2 +b sin а, cos Find the coefficients a, an and b with n> 1. 0 an b = (10-10(-1)^n)/(pin) M M M Consider the function f defined on the interval-5, 5 as follows, { E5,0), те (0,5). 3. f(x) = 3. Denote by fr the Fourier series expansion of...
Find Fourier coefficients for the following function defined on x E [-π, π] Plot the original function and the first three partial sums of the Fourier series S1, S2, S3 on the same plot. Partial sum Sn is the sum of all contributions from the frequencies less than or equal to n, i.e. Sn(x) = a0+ Σ 1 (ak cos(kx) +br sin(kx)) Find Fourier coefficients for the following function defined on x E [-π, π] Plot the original function and...
please code on MATHLAB and show graph thank you in advance! Generate the following function y1(t)=2* sin (2*pi* 1 *t)+4*sin(2*pi*2*t)+3*sin(2*pi*4*t) y2(t)=2*cos(2*pi*1*t)+4*cos(2*pi*2*t)+3*cos(2*pi*4*t) First, required by sampling theorem, the step size of t (delta t) has to be smaller than a value. Figure out this value and set the delta t at least 3 times smaller than this value and calculated y1(t) and y2(t). Increase the step size (delta t) and recalculate y1(t) and y2(t). See the difference. Calculate Fourier Transform of...
11.1 and 11.2 Fourier Series Q1 Find the Fourier series of the given function f(x), which is assumed to have the period 2π. Show the details of your work. Sketch or graph the partial sums up to that including cos 5x and sin 5x. Note: Plot the partial sum using MATLAB. Hint: Make use of your knowledge of the line equation to find f(x) from the given graph. -π 0 11.1 and 11.2 Fourier Series Q1 Find the Fourier series...
(1 point) Solve the wave equation with fixed endpoints and the given initial displacement and velocity. a2 ,0<x<L, t > 0 a(0. t) = 0, u(L, t) = 0, t > 0 Ou Ot ηπα t) + B,, sin (m Now we can solve the PDE using the series solution u(r,t)-> An C computed many times: An example: t) ) sin (-1 ). The coefficients .An and i, are Fourier coefficients we have , cos n-1 sin(n pix/ L) dr...
Exercises: u used to the instructor b the end of next lab. 20 102 Plot the f(t)-sinc(20r) cos(300t)sinc (10t) cos(100t) Use the fast Fourier transform to find the magnitude and phase spectrum of the signal and plot over an appropriate range. Use appropriate values for the time interval and the sampling interval. Note that in Matlab sinc(x)-, so we need to divide the argument by n to make it match the given function. Le, sinc(20t/pi) Hint: Use the parameters from...
You are given a finite step function xt=-1 0<t<4 1 4<t<8. Hand calculate the FS coefficients of x(t) by assuming half- range expansion, for each case below. 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. Modify the code below to approximate x(t) by sine series only (This is odd-half range expansion).. Modify...
This is a MATLAB Question. Below is my base code for a Fourier Series of a half triangle wave. So I am being asked to isolate the first 8 components so that only those first 8 components of the half triangle function are calculated by MATLAB fft function, and then afterwards I am asked to do the same thing but with the first 20 components rather than the first 8. How do I isolate the first x number of components...
To plot a figure of a function y=f(t) in an interval a and b in MATLAB, one should find n-1 points of t between a and b and then find the corresponding values to plot the figure. Below shows an example of a sin function in the range of 0 and 1 with 1000 increments, as well as the figure. >> t = 0:0.001:1; >> y = sin(2*pi*2*t); >> figure >> plot(t, y) 0 02 04 06 08 Demonstrate a...
please do 9 Find a function f(x) with power series f(x) E-1n3 x" 9. 10. Use a power series to show that 0.999...= 1 n(1+1/n) 11. Determine the convergence/divergence of n-11+1/0 12. Find the length of the curve c(t) (Tt+e,2 cos t,2 sin t) for 0t T (1+3) converge? 13. To what value for the sequence an 14. Does the series ne- converge?V 15. Give an example of u, v E R3 perpendicular and with no zero entries in Find...