0% found this document useful (0 votes)
14 views13 pages

Document 11

The document outlines various objectives and explanations related to signal processing using MATLAB, including the effects of changing time intervals on magnitude spectra, periodic repetition of signals, and analysis of non-sinusoidal waveforms. It provides MATLAB code snippets for generating signals, computing their FFT, and visualizing their spectra. Additionally, it discusses the impact of frequency grid adjustments and index changes on signal reconstruction.
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)
14 views13 pages

Document 11

The document outlines various objectives and explanations related to signal processing using MATLAB, including the effects of changing time intervals on magnitude spectra, periodic repetition of signals, and analysis of non-sinusoidal waveforms. It provides MATLAB code snippets for generating signals, computing their FFT, and visualizing their spectra. Additionally, it discusses the impact of frequency grid adjustments and index changes on signal reconstruction.
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/ 13

PART-A

1.
Objective:
 To observe how changing the time interval affects the magnitude
spectrum of a given signal.

Explanation:
 In the original setup, the time interval is from -T/2 to T/2. This is a
symmetric range around zero, which ensures that both positive and
negative frequencies are represented in the magnitude spectrum.
 When changing the time interval to 0 to T, the signal starts at zero and
ends at T, so the signal will be missing the negative frequency
components, potentially causing the magnitude spectrum to show a
distorted or half-wave pattern.
 Changing the interval to -T/4 to 3T/4 will affect the representation of the
signal in both time and frequency domains. The length of the interval
reduces the representation of the signal, which can influence the
frequency resolution.
 Changing the interval to -T to T should return a symmetric frequency
spectrum again, but the time-domain signal will be mirrored.

MATLAB Code:

T = 1; % Period

t1 = -T/2 : 0.001 : T/2; % Original interval from -T/2 to T/2

t2 = 0 : 0.001 : T; % Interval from 0 to T

t3 = -T/4 : 0.001 : 3*T/4; % Interval from -T/4 to 3T/4

% Create the signal x(t)


x1 = cos(2pi5t1); % Example signal, cos(2pi5t) for visualization

x2 = cos(2pi5t2); % Signal for t2

x3 = cos(2pi5t3); % Signal for t3

% Calculate magnitude spectrum using fft

X1 = abs(fft(x1));

X2 = abs(fft(x2));

X3 = abs(fft(x3));

% Plot the magnitude spectrum for each signal

figure;

subplot(3,1,1); plot(abs(fftshift(X1))); title('Magnitude Spectrum for Interval -


T/2 to T/2');

subplot(3,1,2); plot(abs(fftshift(X2))); title('Magnitude Spectrum for Interval 0


to T');

subplot(3,1,3); plot(abs(fftshift(X3))); title('Magnitude Spectrum for Interval -


T/4 to 3T/4');

Explanation of the Code:


 T = 1; sets the period of the signal.
 Different time intervals (t1, t2, t3) are defined.
 x1, x2, and x3 represent cosine signals within these intervals.
 The magnitude spectrum is computed using fft() and visualized with
subplot().

2.
We have stated that c(k+1) = c(k). Modify the code for example 1 and see
whether you get a periodic repetition of c(k).
Objective:
 To modify the code and observe if periodic repetition of c(k) occurs.

Explanation:
 The modification involves changing the relation of c(k) such that
c(k+1) = c(k). By doing so, we expect to see a periodic pattern
emerging from the signal.

MATLAB Code:
N = length(x); % Length of the signal

c = zeros(1, N); % Initialize c(k)

for k = 1:N-1

if mod(k,2) == 0

c(k+1) = c(k); % Set c(k+1) = c(k) as per the requirement

end

end

Explanation of the Code:


 The length of the signal is determined by N = length(x);.
 A loop is used to iterate over the signal, and c(k+1) is set equal to
c(k) for even indices

3.

Take a non-sinusoidal wave, x(t) = 3sin(300πt) - 4cos(900πt) + cos(1200πt) and


determine its spectrum. Consider sampling frequency = 2.4 kHz.
Objective:
 To generate a non-sinusoidal signal and determine its frequency
spectrum.

Explanation:
 The given signal is a combination of sinusoidal and cosine waves. The
FFT (Fast Fourier Transform) will be used to observe its frequency
components.

MATLAB Code:
f1 = 300; % Frequency for 3sin(300πt)

f2 = 900; % Frequency for -4cos(900πt)

f3 = 1200; % Frequency for cos(1200πt)

Fs = 2400; % Sampling frequency 2.4kHz

t = 0:1/Fs:1; % Time vector for 1 second

% Non-sinusoidal signal

x = 3sin(2pif1t) - 4cos(2pif2t) + cos(2pif3*t);

% Plot the signal

figure; plot(t, x);

title('Signal x(t)');

% Frequency spectrum using FFT

X = abs(fft(x));

f = (0:length(X)-1)*Fs/length(X); % Frequency axis

% Plot the magnitude spectrum


figure; plot(f, X);

title('Magnitude Spectrum of x(t)');

xlim([0 1200]);

Explanation of the Code:


 The signal x(t) is generated as a combination of three sinusoidal and
cosine components.
 The frequency spectrum is computed using fft() and plotted against the
frequency axis.

4.
Derive the power density spectrum for a rectangular pulse train and observe
their dual nature in time and frequency domain.

Objective:
 To analyze the power density spectrum of a rectangular pulse train and
observe its characteristics in both time and frequency domains.

Explanation:
 A rectangular pulse train is generated using square(), and its power
density spectrum is calculated using the FFT.

MATLAB Code:

% Parameters for rectangular pulse train

T_pulse = 0.1; % Pulse width

Fs = 1000; % Sampling frequency

t = 0:1/Fs:1; % Time vector for 1 second


% Generate rectangular pulse train

x = square(2pi5t, T_pulse100); % Pulse train with 5 Hz frequency and 10%


duty cycle

% Power density spectrum

X = abs(fft(x)).^2; % Power spectrum

f = (0:length(X)-1)*Fs/length(X); % Frequency axis

% Plot power density spectrum

figure; plot(f, X);

title('Power Density Spectrum of Rectangular Pulse Train');

xlim([0 50]); % Focus on lower frequencies

Explanation of the Code:


 A rectangular pulse train is generated using square().
 The power density spectrum is calculated using the squared magnitude of
the FFT result and then plotted.

PART-B
1.
Increase the range of the frequency grid to [0, 2π]. Observe and explain the
effects.

Explanation:
 Typically, the frequency grid is from [-π, π] or [-2π, 2π]. When you
change the frequency grid to [0, 2π], you only observe the positive
frequency components.
 As a result, the frequency spectrum of the signal will only display the
positive frequency part, and the negative frequency components will be
excluded, which might result in an incomplete representation of the
signal.

MATLAB Code:
% Define frequency grid and time signal

f = linspace(0, 2pi, 1000); % Frequency grid from 0 to 2π

t = linspace(0, 1, 1000); % Time vector

x = cos(2pi5t); % Example signal

% Plotting the magnitude spectrum

X = abs(fft(x));

f_axis = linspace(0, 2*pi, length(X));

figure;

plot(f_axis, X);

title('Magnitude Spectrum for Frequency Grid [0, 2\pi]');

xlabel('Frequency (radians)');

ylabel('Magnitude');

2.
Change the range of the frequency range to [-2π, 2π]. Observe and explain the
effects.

Explanation:
 When you adjust the frequency grid to [-2π, 2π], the signal's frequency
spectrum will include both positive and negative frequencies.
 This allows the signal to be fully represented, and you'll see a symmetric
frequency spectrum around zero.

MATLAB Code:

% Define frequency grid and time signal

f = linspace(-2pi, 2pi, 1000); % Frequency grid from -2π to 2π

x = cos(2pi5*t); % Example signal

% Plotting the magnitude spectrum

X = abs(fft(x));

f_axis = linspace(-2pi, 2pi, length(X));

figure;

plot(f_axis, X);

title('Magnitude Spectrum for Frequency Grid [-2\pi, 2\pi]');

xlabel('Frequency (radians)');

ylabel('Magnitude');

3.
Verify the effect of changing the index (n) to -40:120, -40:80. In each case
observe the reconstructed signal.

Explanation:
 Changing the index n will affect the reconstruction of the signal.
 If n = -40:120, the reconstructed signal will be based on a broader range
of indices, providing more information.
 If n = -40:80, the signal will have a smaller time range and some
information will be omitted, affecting the reconstructed signal's quality.

MATLAB Code:
% Define signal and indices

n1 = -40:120;

n2 = -40:80;

% Reconstruct signal with different indices

x1 = cos(2pi5n1);

x2 = cos(2pi5n2);

figure;

subplot(2,1,1);

plot(n1, x1);

title('Reconstructed Signal for n = -40:120');

subplot(2,1,2);

plot(n2, x2);

title('Reconstructed Signal for n = -40:80');

4.
If you reconstruct the signal in n_re=240:240, why do you get a repetition of the
aperiodic signal? Explain.
Explanation:
 Reconstructing the signal with n_re=240:240 leads to a repetition of the
aperiodic signal because the index range forces the signal to repeat from
its starting point.
 This repetition occurs due to the periodic nature of the reconstruction
when the time range is not large enough to represent the full signal.

MATLAB Code:

% Reconstructing the signal with n_re=240:240


n_re = 240:240;
x_re = cos(2pi5*n_re);

figure;

plot(n_re, x_re);

title('Reconstructed Aperiodic Signal for n_re=240:240');

5
Consider the continuous time signal shown in Fig. 16. Sample it and then find
out the Fourier transform in terms of the analog frequency.

Explanation:
 You are given a continuous time signal, which will be sampled at a
specific frequency.
 After sampling the signal, you need to calculate the Fourier Transform to
analyze the frequency components in terms of the analog frequency.

MATLAB Code:
% Sample the continuous signal

t_cont = linspace(0, 1, 1000);

x_cont = cos(2pi5*t_cont);

% Sampled signal

Fs = 10; % Sampling frequency

t_sampled = 0:1/Fs:1;

x_sampled = cos(2pi5*t_sampled);

% Fourier Transform of the sampled signal

X_sampled = abs(fft(x_sampled));

figure;

subplot(2,1,1);

plot(t_cont, x_cont);

title('Continuous Time Signal');

subplot(2,1,2);

f_sampled = linspace(0, Fs, length(X_sampled));

plot(f_sampled, X_sampled);

title('Fourier Transform of Sampled Signal');

You might also like