Experiment 2 1
Experiment 2 1
EQUIPMENTS:
Operating System – Windows XP
Constructor - Simulator
Software - MATLAB 2012a
Theory
Signals Definition:
Operations:
Addition: y(t)=x1(t)+x2(t)
Subtraction: y(t)=x1(t)−x2(t)
Multiplication: y(t)=x1(t)⋅x2(t)
Division: y(t)=x1(t)/x2(t)
Program:
clc;
clear;
close all;
% Define the time vector
t = -10:0.01:10;
% Define two example signals
x1 = sin(2*pi*0.1*t); % Signal 1: Sine wave
x2 = cos(2*pi*0.1*t); % Signal 2: Cosine wave
% Perform operations
signal_addition = x1 + x2; % Addition
signal_subtraction = x1 - x2; % Subtraction
signal_multiplication = x1 .* x2; % Multiplication (pointwise)
signal_division = x1 ./ (x2 + 1e-6); % Division (avoid division by zero)
% Plot the signals and results
figure;
% Plot Signal 1
subplot(3,2,1);
plot(t, x1, 'b', 'LineWidth', 1.5);
title('Signal 1 (x1)');
xlabel('Time');
ylabel('Amplitude');
grid on;
% Plot Signal 2
subplot(3,2,2);
plot(t, x2, 'r', 'LineWidth', 1.5);
title('Signal 2 (x2)');
xlabel('Time');
ylabel('Amplitude');
grid on;
% Plot Signal Addition
subplot(3,2,3);
plot(t, signal_addition, 'g', 'LineWidth', 1.5);
title('Signal Addition (x1 + x2)');
xlabel('Time');
ylabel('Amplitude');
grid on;
% Plot Signal Subtraction
subplot(3,2,4);
plot(t, signal_subtraction, 'm', 'LineWidth', 1.5);
title('Signal Subtraction (x1 - x2)');
xlabel('Time');
ylabel('Amplitude');
grid on;
% Plot Signal Multiplication
subplot(3,2,5);
plot(t, signal_multiplication, 'k', 'LineWidth', 1.5);
title('Signal Multiplication (x1 .* x2)');
xlabel('Time');
ylabel('Amplitude');
grid on;
% Plot Signal Division
subplot(3,2,6);
plot(t, signal_division, 'c', 'LineWidth', 1.5);
title('Signal Division (x1 ./ x2)'); xlabel('Time');
ylabel('Amplitude');
grid on;
disp('Program executed successfully.');
PROCEDURE:
1. Open the Mat lab software by clicking on icon.
2. Create a new file (filenew.m file).
3. Now type the program in that file.
4. Save the program as .m file(filesave)
5. Run the program(debugrun)
6. Observe the output plots.
RESULT: Analog and Discrete time signals are observed and results are plotted using MATLAB