0% found this document useful (0 votes)
21 views

Signal operations - PART 1

The document provides MATLAB code examples for various signal operations including addition, multiplication, scaling, and time shifting of discrete and continuous signals. It demonstrates how to plot these operations using stem and plot functions for visual representation. Each section includes comments explaining the purpose and functionality of the code.

Uploaded by

pranesh1362006
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
21 views

Signal operations - PART 1

The document provides MATLAB code examples for various signal operations including addition, multiplication, scaling, and time shifting of discrete and continuous signals. It demonstrates how to plot these operations using stem and plot functions for visual representation. Each section includes comments explaining the purpose and functionality of the code.

Uploaded by

pranesh1362006
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 3

Signal Operations in MATLAB

Addition (DT)

x=[1 2 3 4];
subplot(3,1,1);
stem(x);
title('X');
y=[1 1 1 1];
subplot(3,1,2);
stem(y);
title('Y');
z=x+y;
subplot(3,1,3);
stem(z);
title('Z=X+Y');

Addition Program 2 (CT)

t = 0:0.01:1; % Time vector


signal1 = sin(2*pi*5*t); % First signal: Sine wave
signal2 = cos(2*pi*5*t); % Second signal: Cosine wave

% Add the signals


result = signal1 + signal2;

% Plot the result


figure;
plot(t, result);
title('Addition of Signals');
xlabel('Time (s)');
ylabel('Amplitude');
grid on;

Multiplication of Signals
% Define two signals
t = 0:0.01:1; % Time vector
signal1 = sin(2*pi*5*t); % First signal: Sine wave
signal2 = cos(2*pi*5*t); % Second signal: Cosine wave

% Multiply the signals


result = signal1 .* signal2;

% Plot the result


figure;
plot(t, result);
title('Multiplication of Signals');
xlabel('Time (s)');
ylabel('Amplitude');
grid on;
Scaling of a Signal
% Define a signal
t = 0:0.01:1; % Time vector
signal = sin(2*pi*5*t); % Signal: Sine wave

% Scale the signal


scaling_factor = 2;
result = scaling_factor * signal;

% Plot the result


figure;
plot(t, result);
title('Scaling of Signal');
xlabel('Time (s)');
ylabel('Amplitude');
grid on;

Time Shifting (Delay and Advancing)

t=0:10;

x=[0 1 2 1 0 1 2 0 1 2 1 ];

subplot(3,1,1)

plot(t,x)

title('Simple Signal')

xlabel('Time')

ylabel('Amplitude')

grid on;

axis([-2 8 0 4]);

subplot(3,1,2)

plot(t+2,x)

title('Shifting by addition')

xlabel('Time')

ylabel('Amplitude')

grid on;

axis([-2 8 0 4]);

subplot(3,1,3)

plot(t-2,x)

title('Shifting by Subtraction')
xlabel('Time')

ylabel('Amplitude')

grid on;

axis([-2 8 0 4]);

You might also like