0% found this document useful (0 votes)
32 views3 pages

Experiment 7

Important

Uploaded by

mannammanikanta7
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
32 views3 pages

Experiment 7

Important

Uploaded by

mannammanikanta7
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 3

Experiement-7

MATLAB program Fourier Expansion of given signal

AIM: To analyze and reconstruct Exponential Fourier Series and compute its Fourier
coefficients, magnitude spectrum, and phase spectrum using MATLAB.
EQUIPMENTS:
Operating System – Windows XP
Constructor - Simulator
Software - MATLAB 2012a

Theory

Program:
% Exponential Fourier Series of a Continuous-Time Signal
clc;
clear;
close all;

% Define the periodic signal


T = 2; % Signal period
omega0 = 2 * pi / T; % Fundamental angular frequency
t = -2*T:0.001:2*T; % Time vector
x_t = square(2*pi*t/T); % Periodic square wave

% Number of Fourier series terms


N = 10; % Number of terms (positive and negative)
% Calculate Fourier coefficients
C_k = zeros(1, 2*N+1); % Coefficients from -N to N
k_vals = -N:N; % Indices from -N to N

for k = k_vals
% Integral over one period (numerical integration using trapz)
integrand = @(t) square(2*pi*t/T) .* exp(-1j*k*omega0*t);
C_k(k + N + 1) = (1/T) * integral(integrand, 0, T);
end

% Reconstruct the signal using the Fourier series


x_reconstructed = zeros(size(t));
for k = k_vals
x_reconstructed = x_reconstructed + C_k(k + N + 1) * exp(1j * k * omega0 *
t);
end

% Plot the original and reconstructed signals


figure;

% Original signal
subplot(3,1,1);
plot(t, x_t, 'LineWidth', 1.5);
xlabel('Time (t)');
ylabel('x(t)');
title('Original Signal');
grid on;

% Magnitude of Fourier Coefficients


subplot(3,1,2);
stem(k_vals, abs(C_k), 'LineWidth', 1.5);
xlabel('k');
ylabel('|C_k|');
title('Magnitude Spectrum');
grid on;

% Phase of Fourier Coefficients


subplot(3,1,3);
stem(k_vals, angle(C_k), 'LineWidth', 1.5);
xlabel('k');
ylabel('Phase (radians)');
title('Phase Spectrum');
grid on;

PROCEDURE:
1. Open the Mat lab software by clicking on icon.
2. Create a new file (file🡪new🡪.m file).
3. Now type the program in that file.
4. Save the program as .m file(file🡪save)
5. Run the program(debug🡪run)
6. Observe the output plots.

RESULT: Exponential Fourier Series and compute its Fourier coefficients, magnitude spectrum, and
phase spectrum using MATLAB is observed.

You might also like