During lab 4, we have seen numerical implementation of Fourier Series for periodic signals. As first...

60.1K

Verified Solution

Question

Electrical Engineering

During lab 4, we have seen numerical implementation of FourierSeries for periodic signals. As first part of this assignment, youneed to write a Matlab function that would take an arrayrepresenting a single period of a signal (x), corresponding timearray (t), and return the Fourier Series coefficients (Ck) inexponential form. The function should also be able to take two (2)optional input arguments: number of Fourier coefficients (Nk) andplot option (p). Use the template ‘fourier_series_exp.m’ for thisproblem.

(Template \"fourier_series_exp.m\")

function [Ck]=fourier_series_exp(x,t,Nk,p)

% Ck = exponential fourier series cofficient
% x = single period of a signal
% t = time corrosponding to 'x'
% Nk = (optional input) number of exponential terms
% p = plotting option ; p=0, no plots, p = 1 plot Ck vs k andreconstructed signal
% dT = t(2)-t(1) = temporal resolution of signal (x)
% T = peiod of signal 'x'
% w0= angular frequency of signal 'x'


dT=t(2)-t(1);
T= dT*length(t);
w0=2*pi/T;   

% Check the number of inputs, 'nargin' returns number of inputarguments
if nargin <2
error('Not enough input argument!')
elseif nargin == 2
Nk=101; % you can set any default value you like
p=0; % not plots
elseif nargin ==3
p=0; % not plots
end
k=-floor(Nk/2):floor(Nk/2); % if Nk=11, k=-5:5; if Nk=12,k=-6:6


%% evaluate Ck
%
% % % write this code segment
%
%% plot spectrum and reconstructed signal   
if p==1
% plot abs(Ck) vs k and angle(Ck) vs k
%
% % % write this code segment
%
  
% plot 3 cycles of the signal 'x' and the reconstructedsignal
%
% % % write this code segment
%
end

end

Answer & Explanation Solved by verified expert
4.4 Ratings (956 Votes)
function CkfourierseriesexpxtNkp Ck exponential fourier series cofficient x single    See Answer
Get Answers to Unlimited Questions

Join us to gain access to millions of questions and expert answers. Enjoy exclusive benefits tailored just for you!

Membership Benefits:
  • Unlimited Question Access with detailed Answers
  • Zin AI - 3 Million Words
  • 10 Dall-E 3 Images
  • 20 Plot Generations
  • Conversation with Dialogue Memory
  • No Ads, Ever!
  • Access to Our Best AI Platform: Flex AI - Your personal assistant for all your inquiries!
Become a Member

Other questions asked by students