all programs
all programs
% Plotting
plot(t, unit_step_signal, 'b', 'LineWidth', 2);
title('Unit Step Signal');
xlabel('Time');
ylabel('Amplitude');
grid on;
b) Rectangular
% Define the time range
t = -5:0.01:5;
% Plotting
plot(t, rectangular_signal, 'r', 'LineWidth', 2);
title('Rectangular Signal');
xlabel('Time');
ylabel('Amplitude');
grid on;
c) Standard Triangle
% Define the time range
t = -5:0.01:5;
% Plotting
plot(t, standard_triangle_signal, 'g', 'LineWidth', 2);
title('Standard Triangle Signal');
xlabel('Time');
ylabel('Amplitude');
grid on;
d) Sinusoidal
% Define the time range
t = -5:0.01:5;
% Plotting
plot(t, sinusoidal_signal, 'm', 'LineWidth', 2);
title('Sinusoidal Signal');
xlabel('Time');
ylabel('Amplitude');
grid on;
e) Exponential signal
% Define the time range
t = -5:0.01:5;
% Plotting
plot(t, exponential_signal, 'c', 'LineWidth', 2);
title('Exponential Signal');
xlabel('Time');
ylabel('Amplitude');
grid on;
All the a, b, c, d and e programs in one
% Define the time range
t = -5:0.01:5;
% b) Rectangular Signal
width_rectangular = 2;
rectangular_signal = double(abs(t) <= width_rectangular/2);
% d) Sinusoidal Signal
frequency_sine = 1;
phase_sine = pi/4;
sinusoidal_signal = sin(2*pi*frequency_sine*t + phase_sine);
% e) Exponential Signal
alpha_exp = 0.5;
exponential_signal = exp(alpha_exp * t);
% Plotting
figure;
subplot(3, 2, 1);
plot(t, unit_step_signal, 'b', 'LineWidth', 2);
title('Unit Step Signal');
xlabel('Time');
ylabel('Amplitude');
grid on;
subplot(3, 2, 2);
plot(t, rectangular_signal, 'r', 'LineWidth', 2);
title('Rectangular Signal');
xlabel('Time');
ylabel('Amplitude');
grid on;
subplot(3, 2, 3);
plot(t, standard_triangle_signal, 'g', 'LineWidth', 2);
title('Standard Triangle Signal');
xlabel('Time');
ylabel('Amplitude');
grid on;
subplot(3, 2, 4);
plot(t, sinusoidal_signal, 'm', 'LineWidth', 2);
title('Sinusoidal Signal');
xlabel('Time');
ylabel('Amplitude');
grid on;
subplot(3, 2, 5);
plot(t, exponential_signal, 'c', 'LineWidth', 2);
title('Exponential Signal');
xlabel('Time');
ylabel('Amplitude');
grid on;
% Adjusting layout
sgtitle('Basic Signals and Signal Graphing');
2. Illustration of signal representation in time and frequency domains for a rectangular pulse.
% Define time vector
t = -1:0.01:1;
% Plotting
figure;
% Carrier signal
c = sin(pi*Fc*t);
% Demodulation
s_demod = s .* c; % Demodulation by multiplying with carrier
% Plotting
figure;
subplot(3, 1, 2);
plot(t, c, 'r', 'LineWidth', 2);
title('Carrier Signal');
xlabel('Time (s)');
ylabel('Amplitude');
grid on;
subplot(3, 1, 3);
plot(t, s, 'm', 'LineWidth', 2);
hold on;
plot(t, s_demod, 'g', 'LineWidth', 2);
title('Modulated and Demodulated Signals');
xlabel('Time (s)');
ylabel('Amplitude');
legend('Modulated Signal', 'Demodulated Signal');
grid on;
4. Frequency Modulation and Demodulation: Generation and display the relevant signals and
its spectrum.
% Parameters
Fs = 1000; % Sampling frequency (Hz)
T = 1/Fs; % Sampling period
L = 1000; % Length of signal
t = (0:L-1)*T; % Time vector
Fc = 100; % Carrier frequency (Hz)
Fm = 10; % Modulating frequency (Hz)
kf = 50; % Frequency deviation constant (Hz/V)
m = sin(2*pi*Fm*t); % Modulating signal (message signal)
% Frequency Modulation
s_fm = cos(2*pi*Fc*t + kf*cumsum(m));
% Frequency Demodulation
s_demod = diff(s_fm);
% Plotting
figure;
% Adjusting layout
sgtitle('Frequency Modulation and Demodulation (Simple Version)');
5. Sampling and reconstruction of low pass signals. Display the signals and its spectrum.
% Parameters
Fs = 1000; % Sampling frequency (Hz)
T = 1/Fs; % Sampling period
L = 1000; % Length of signal
t = (0:L-1)*T; % Time vector
Fc = 50; % Cutoff frequency of low-pass filter (Hz)
Am = 0.7; % Amplitude of the signal
Fm = 10; % Frequency of the signal (Hz)
% Sampling
Fs_new = 400; % New sampling frequency (Hz)
T_new = 1 / Fs_new; % New sampling period
t_new = 0:T_new:t(end); % New time vector
m_sampled = interp1(t, m_lp, t_new, 'linear');
% Reconstruction
m_reconstructed = interp1(t_new, m_sampled, t, 'linear');
% Plotting
figure;
% Adjusting layout
sgtitle('Sampling and Reconstruction of Low Pass Signals');
6. Time Division Multiplexing and Demultiplexing.
Fs = 1000; % Sampling frequency
duration = 10; % Duration of the signals (seconds)
subplot(num_signals+1, 1, 2);
plot(t, signal2);
title('Original Signal 2');
xlabel('Time (s)');
ylabel('Amplitude');
subplot(num_signals+1, 1, num_signals+1);
plot(t, combined_signal(1, :), 'b', t, combined_signal(2, :), 'r');
title('Multiplexed Signal');
xlabel('Time (s)');
ylabel('Amplitude');
legend('Signal 1', 'Signal 2');
OR
% Define parameters
Fs = 1000; % Sampling frequency
duration = 10; % Duration of the signals (seconds)
num_signals = 2; % Number of signals to multiplex
subplot(num_signals+2, 1, 2);
plot(t, signal2);
title('Original Signal 2');
xlabel('Time (s)');
ylabel('Amplitude');
subplot(num_signals+2, 1, num_signals+2);
plot(t, combined_signal(1, :), 'b', t, combined_signal(2, :), 'r');
title('Multiplexed Signal');
xlabel('Time (s)');
ylabel('Amplitude');
legend('Signal 1', 'Signal 2');
x=a*sin(2*pi*f*t);
subplot(3,2,1)
plot(t,x)
title('figure.1 Analog signal');
x1=x+2;
subplot(3,2,2)
plot(t,x1)
title('figure.2 Amplitude Shifted Analog signal');
subplot(3,2,3)
stem(t,x1)
title('figure.3 Sampled Analog signal');
q=round(x1);
subplot(3,2,4)
stem(t,q)
title('figure.4 Quantized signal');
enco=de2bi(q,'left-msb');
subplot(3,2,5)
plot(t,enco)
title('figure.5 PCM encodedsignal');
%pcm decoding
deco=bi2de(enco,'left-msb');
subplot(3,2,6)
plot(t,deco)
title('figure.6 PCM Decoded signal');
8. Generate
a) NRZ, RZ and Raised Cosine pulse
b) Generate and plot eye diagram
% Parameters
Fs = 1000; % Sampling frequency (Hz)
T = 1/Fs; % Sampling period
L = 1000; % Length of signal
t = (0:L-1)*T; % Time vector
subplot(3,1,2);
plot(t, rz_pulse, 'LineWidth', 2);
title('RZ (Return-to-Zero) Pulse');
xlabel('Time (s)');
ylabel('Amplitude');
grid on;
subplot(3,1,3);
plot(t_rc, rc_pulse, 'LineWidth', 2);
title('Raised Cosine Pulse');
xlabel('Time (s)');
ylabel('Amplitude');
grid on;
hold off;
% Generate x values
x = linspace(-5, 5, 1000); % Range of x values