1.
MATLAB program to generate SSB waveform
Aim:
Program to generate SSB waveform
Procedure:
1.Open MATLAB: Open the MATLAB software on your computer.
2. Create a New Script: Click on the "New Script" button in the MATLAB .
3. Type Your Code: Type or copy-paste your MATLAB code. Make sure to use
proper syntax, including variable names, functions and conditional statements.
4. Save Your Script: Save your script.
5. Run Your Code: Click on the "Run" button in the toolbar.
6. View the Output: After running the code, MATLAB will display the output in
the Command Window. If your code produces any plots or graphical output,
they will appear in separate figure windows.
8.Modify and Repeat: If needed, modify your code based on the output or any
errors encountered during execution.
9.Close MATLAB: Once you are done with your work, you can close MATLAB by
clicking on the "Close" button.
Codes:
% Parameters
Fs = 1000; % Sampling frequency
T = 1; % Duration of the signal in seconds
t = 0:1/Fs:T-1/Fs; % Time vector
% Message signal (e.g., a simple sinusoid)
f_message = 10; % Message frequency
message_signal = cos(2*pi*f_message*t); % Message signal
% Carrier signal
f_carrier = 100; % Carrier frequency
carrier_signal = cos(2*pi*f_carrier*t); % Carrier signal
% Create the analytic signal using the Hilbert transform
analytic_signal = hilbert(message_signal);
% Generate the SSB signal (Upper Sideband)
ssb_upper = real(analytic_signal .* exp(1j*2*pi*f_carrier*t));
% Generate the SSB signal (Lower Sideband)
1
ssb_lower = real(analytic_signal .* exp(-1j*2*pi*f_carrier*t));
% Plot the signals
figure;
subplot(4,1,1);
plot(t, message_signal);
title('Message Signal');
xlabel('Time (s)');
ylabel('Amplitude');
subplot(4,1,2);
plot(t, carrier_signal);
title('Carrier Signal');
xlabel('Time (s)');
ylabel('Amplitude');
subplot(4,1,3);
plot(t, ssb_upper);
title('SSB Signal (Upper Sideband)');
xlabel('Time (s)');
ylabel('Amplitude');
subplot(4,1,4);
plot(t, ssb_lower);
title('SSB Signal (Lower Sideband)');
xlabel('Time (s)');
ylabel('Amplitude');
Output:
Result:
Program to generate SSB waveform is successfully executed
2
2.MATLAB program to generate VSB waveform
Aim:
Program to generate VSB waveform
Procedure:
1.Open MATLAB: Open the MATLAB software on your computer.
2. Create a New Script: Click on the "New Script" button in the MATLAB .
3. Type Your Code: Type or copy-paste your MATLAB code. Make sure to use
proper syntax, including variable names, functions and conditional statements.
4. Save Your Script: Save your script.
5. Run Your Code: Click on the "Run" button in the toolbar.
6. View the Output: After running the code, MATLAB will display the output in
the Command Window. If your code produces any plots or graphical output,
they will appear in separate figure windows.
8.Modify and Repeat: If needed, modify your code based on the output or any
errors encountered during execution.
9.Close MATLAB: Once you are done with your work, you can close MATLAB by
clicking on the "Close" button.
Codes:
% Parameters
Fs = 1000; % Sampling frequency
T = 1; % Duration in seconds
t = 0:1/Fs:T-1/Fs; % Time vector
% Message signal
fm = 10; % Message frequency
m = cos(2*pi*fm*t); % Message signal
% Carrier signal
fc = 100; % Carrier frequency
c = cos(2*pi*fc*t); % Carrier signal
% Generate the analytic signal (Hilbert transform)
m_analytic = hilbert(m);
% Generate DSB signal
dsb = m .* cos(2*pi*fc*t);
% Design VSB filter
3
% This is an example low-pass filter design for VSB modulation
filterOrder = 101;
cutoffFreq = (fc+fm/2) / (Fs/2); % Normalized cutoff frequency
h = fir1(filterOrder, cutoffFreq); % FIR filter design
% Apply VSB filter to DSB signal
vsb = filter(h, 1, dsb);
% Plot the signals
figure;
subplot(3,1,1);
plot(t, m);
title('Message Signal');
xlabel('Time (s)');
ylabel('Amplitude');
subplot(3,1,2);
plot(t, dsb);
title('DSB Signal');
xlabel('Time (s)');
ylabel('Amplitude');
subplot(3,1,3);
plot(t, vsb);
title('VSB Signal');
xlabel('Time (s)');
ylabel('Amplitude');
Output:
Result:Program to generate VSB waves successfully executed.
4
3.MATLAB program to verify sampling of bandlimited signal
Aim: Program to verify sampling of bandlimited signal.
Procedure:
1.Open MATLAB: Open the MATLAB software on your computer.
2. Create a New Script: Click on the "New Script" button in the MATLAB .
3. Type Your Code: Type or copy-paste your MATLAB code. Make sure to use
proper syntax, including variable names, functions and conditional statements.
4. Save Your Script: Save your script.
5. Run Your Code: Click on the "Run" button in the toolbar.
6. View the Output: After running the code, MATLAB will display the output in
the Command Window. If your code produces any plots or graphical output,
they will appear in separate figure windows.
8.Modify and Repeat: If needed, modify your code based on the output or any
errors encountered during execution.
9.Close MATLAB: Once you are done with your work, you can close MATLAB by
clicking on the "Close" button.
Codes:
% Parameters
Fs = 1000; % Original signal sampling frequency (Hz)
T = 1; % Duration of the signal (seconds)
t = 0:1/Fs:T; % Time vector
f = 50; % Frequency of the band-limited signal (Hz)
% Create a band-limited signal (sine wave)
x = sin(2*pi*f*t);
% Define the new sampling frequency (Nyquist rate is 2*f)
Fs_new = 2*f; % New sampling frequency (Hz)
T_new = 1/Fs_new; % New sampling period (seconds)
t_new = 0:T_new:T; % New time vector
% Sample the signal at the new sampling rate
x_sampled = sin(2*pi*f*t_new);
% Reconstruct the signal using interpolation
x_reconstructed = interp1(t_new, x_sampled, t, 'spline');
% Plot the original signal, sampled signal, and reconstructed signal
5
figure;
subplot(3,1,1);
plot(t, x);
title('Original Signal');
xlabel('Time (s)');
ylabel('Amplitude');
subplot(3,1,2);
stem(t_new, x_sampled, 'r');
title('Sampled Signal');
xlabel('Time (s)');
ylabel('Amplitude');
subplot(3,1,3);
plot(t, x, 'b', t, x_reconstructed, 'r--');
title('Reconstructed Signal');
xlabel('Time (s)');
ylabel('Amplitude');
legend('Original Signal', 'Reconstructed Signal');
% Display the error between the original and reconstructed signals
error = x - x_reconstructed;
figure;
plot(t, error);
title('Error between Original and Reconstructed Signals');
xlabel('Time (s)');
ylabel('Error');
Output:
Result:
Program on verification of sampling bandlimited signal is successfully executed
6
4.MATLAB program to TDM and de-multiplexing
Aim:
Program to generate TDM and demultiplexing
Procedure:
1.Open MATLAB: Open the MATLAB software on your computer.
2. Create a New Script: Click on the "New Script" button in the MATLAB .
3. Type Your Code: Type or copy-paste your MATLAB code. Make sure to use
proper syntax, including variable names, functions and conditional statements.
4. Save Your Script: Save your script.
5. Run Your Code: Click on the "Run" button in the toolbar.
6. View the Output: After running the code, MATLAB will display the output in
the Command Window. If your code produces any plots or graphical output,
they will appear in separate figure windows.
8.Modify and Repeat: If needed, modify your code based on the output or any
errors encountered during execution.
9.Close MATLAB: Once you are done with your work, you can close MATLAB by
clicking on the "Close" button.
Codes:
% Define time parameters
Fs = 1000; % Sampling frequency
T = 1/Fs; % Sampling period
L = 1000; % Length of signal
t = (0:L-1)*T; % Time vector
% Define three different signals
signal1 = sin(2*pi*50*t); % 50 Hz sine wave
signal2 = square(2*pi*30*t); % 30 Hz square wave
signal3 = sawtooth(2*pi*20*t); % 20 Hz sawtooth wave
% TDM - Multiplexing
tdm_signal = zeros(1, L * 3);
tdm_signal(1:3:end) = signal1;
tdm_signal(2:3:end) = signal2;
tdm_signal(3:3:end) = signal3;
% Plot original signals
figure;
subplot(4,1,1);
plot(t, signal1);
7
title('Original Signal 1 (50 Hz sine wave)');
xlabel('Time (s)');
ylabel('Amplitude');
subplot(4,1,2);
plot(t, signal2);
title('Original Signal 2 (30 Hz square wave)');
xlabel('Time (s)');
ylabel('Amplitude');
subplot(4,1,3);
plot(t, signal3);
title('Original Signal 3 (20 Hz sawtooth wave)');
xlabel('Time (s)');
ylabel('Amplitude');
subplot(4,1,4);
plot(0:T:T*length(tdm_signal)-T, tdm_signal);
title('TDM Signal');
xlabel('Time (s)');
ylabel('Amplitude');
% TDM - Demultiplexing
demux_signal1 = tdm_signal(1:3:end);
demux_signal2 = tdm_signal(2:3:end);
demux_signal3 = tdm_signal(3:3:end);
% Plot demultiplexed signals
figure;
subplot(3,1,1);
plot(t, demux_signal1);
title('Demultiplexed Signal 1');
xlabel('Time (s)');
ylabel('Amplitude');
subplot(3,1,2);
plot(t, demux_signal2);
title('Demultiplexed Signal 2');
xlabel('Time (s)');
ylabel('Amplitude');
subplot(3,1,3);
plot(t, demux_signal3);
title('Demultiplexed Signal 3');
xlabel('Time (s)');
ylabel('Amplitude');
8
Output:
Result:
Program to generate TDM and demultiplexing successfully executed.
9
5.MATLAB program for generation and delection of PPM and PWM
Aim:
Program for generation and delection of PPM and PWM .
Procedure:
1.Open MATLAB: Open the MATLAB software on your computer.
2. Create a New Script: Click on the "New Script" button in the MATLAB .
3. Type Your Code: Type or copy-paste your MATLAB code. Make sure to use
proper syntax, including variable names, functions and conditional statements.
4. Save Your Script: Save your script.
5. Run Your Code: Click on the "Run" button in the toolbar.
6. View the Output: After running the code, MATLAB will display the output in
the Command Window. If your code produces any plots or graphical output,
they will appear in separate figure windows.
8.Modify and Repeat: If needed, modify your code based on the output or any
errors encountered during execution.
9.Close MATLAB: Once you are done with your work, you can close MATLAB by
clicking on the "Close" button.
Codes:
5.1(Pulse Position Modulation)
% Parameters
Fs = 1000; % Sampling frequency
T = 1; % Duration of the signal in seconds
t = 0:1/Fs:T-1/Fs; % Time vector
% Message signal (e.g., a simple sinusoid)
f_message = 5; % Message frequency (Hz)
message_signal = sin(2*pi*f_message*t);
% Carrier signal for PPM
f_carrier_ppm = 50; % Carrier frequency for PPM (Hz)
carrier_ppm = sin(2*pi*f_carrier_ppm*t); % Square wave carrier
% PPM Modulation
ppm_signal = zeros(size(t));
ppm_indices = round(linspace(1, length(t), 10)); % PPM pulse
positions
10
ppm_signal(ppm_indices) = message_signal(ppm_indices);
% Plotting
figure;
subplot(3,1,1);
plot(t, message_signal);
title('Message Signal');
xlabel('Time (s)');
ylabel('Amplitude');
subplot(3,1,2);
plot(t, carrier_ppm);
title('Carrier Signal (PPM)');
xlabel('Time (s)');
ylabel('Amplitude');
subplot(3,1,3);
stem(t, ppm_signal);
title('PPM Signal');
xlabel('Time (s)');
ylabel('Amplitude');
% PPM Demodulation
demod_ppm_signal = ppm_signal .* carrier_ppm;
% Low-pass filter to recover the message signal
Fc_lp = 10; % Cut-off frequency of the low-pass filter
[b, a] = butter(5, Fc_lp/(Fs/2), 'low'); % Butterworth filter design
recovered_message_ppm = filtfilt(b, a, demod_ppm_signal);
% Plotting
figure;
subplot(3,1,1);
stem(t, ppm_signal);
title('Received PPM Signal');
xlabel('Time (s)');
ylabel('Amplitude');
subplot(3,1,2);
plot(t, demod_ppm_signal);
title('Demodulated PPM Signal');
xlabel('Time (s)');
ylabel('Amplitude');
subplot(3,1,3);
plot(t, recovered_message_ppm);
title('Recovered Message Signal (PPM)');
xlabel('Time (s)');
ylabel('Amplitude');
11
Output:
5.2(Pulse Width Modulation)
% Parameters
Fs = 1000; % Sampling frequency
T = 1; % Duration of the signal in seconds
t = 0:1/Fs:T-1/Fs; % Time vector
% Message signal (e.g., a simple sinusoid)
f_message = 5; % Message frequency (Hz)
message_signal = sin(2*pi*f_message*t);
12
% Carrier signal for PWM
f_carrier_pwm = 100; % Carrier frequency for PWM (Hz)
carrier_pwm = square(2*pi*f_carrier_pwm*t); % Square wave carrier
% PWM Modulation
pwm_signal = message_signal .* carrier_pwm;
% Plotting
figure;
subplot(3,1,1);
plot(t, message_signal);
title('Message Signal');
xlabel('Time (s)');
ylabel('Amplitude');
subplot(3,1,2);
plot(t, carrier_pwm);
title('Carrier Signal (PWM)');
xlabel('Time (s)');
ylabel('Amplitude');
subplot(3,1,3);
plot(t, pwm_signal);
title('PWM Signal');
xlabel('Time (s)');
ylabel('Amplitude');
% PWM Demodulation
demod_pwm_signal = pwm_signal .* carrier_pwm;
% Low-pass filter to recover the message signal
Fc_lp = 10; % Cut-off frequency of the low-pass filter
[b, a] = butter(5, Fc_lp/(Fs/2), 'low'); % Butterworth filter design
recovered_message = filtfilt(b, a, demod_pwm_signal);
% Plotting
figure;
subplot(3,1,1);
plot(t, pwm_signal);
title('Received PWM Signal');
xlabel('Time (s)');
ylabel('Amplitude');
subplot(3,1,2);
plot(t, demod_pwm_signal);
title('Demodulated PWM Signal');
xlabel('Time (s)');
ylabel('Amplitude');
13
subplot(3,1,3);
plot(t, recovered_message);
title('Recovered Message Signal');
xlabel('Time (s)');
ylabel('Amplitude');
Output:
Result:
Program to for generation and delection on PPM and PWM is successfully
executed.
14