0% found this document useful (0 votes)
8 views5 pages

Signal

The document contains MATLAB code snippets for generating and plotting various types of signals including original and shifted sine signals, amplitude-scaled signals, signum signals (both standard and manually implemented), triangle signals (both standard and manually implemented), exponential signals, and corrected parabolic signals. Each signal is plotted with appropriate titles, labels, and grid settings. The code demonstrates different signal processing techniques and visualizations in MATLAB.

Uploaded by

143dalin
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
8 views5 pages

Signal

The document contains MATLAB code snippets for generating and plotting various types of signals including original and shifted sine signals, amplitude-scaled signals, signum signals (both standard and manually implemented), triangle signals (both standard and manually implemented), exponential signals, and corrected parabolic signals. Each signal is plotted with appropriate titles, labels, and grid settings. The code demonstrates different signal processing techniques and visualizations in MATLAB.

Uploaded by

143dalin
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 5

Original Signal

n = 0:0.2:4;
x = sin (2*pi*n);
subplot (2, 1, 1);
plot (n, x, ‘linewidth’ 2);
title (‘original signal’);
xlabel (‘Time’)
ylabel (‘Amplitude’);
grid;
subplot (2, 1, 2);
plot (n-1, x, ‘linewidth’ ,2);
title (‘shift signal’);
xlabel (‘Time’);
ylabel (‘Amplitude’);
grid;

Shift Signal

n = 0:0.02:4;
x = sin(2*pi*n);
subplot (2, 1, 1);
plot (n, x, ‘linewidth’ ,2)
title (‘original signal’);
xlabel (‘Time’)
ylabel (‘Amplitude’);
grid;
subplot (2, 1, 2);
plot (n-1, x, ‘linewidth’);
title (‘shift signal’);
xlabel (‘Time’);
ylabel (‘Amplitude’);
grid;
axis ([-3 4 -1 1]);
subplot (2, 1, 1);
axis ([-3 4 -1 1]);
Amplitude scaling signal
n = 1:7;
x = [1 2 2 3 2 2 1];
subplot (2, 1, 1);
plot (n, x, ‘filled’);
title (‘original signal’);
ylabel (‘Amplitude’);
axis ([1 7 0 4]);
stem (n, x);
stem (n, x, ‘filled’);
s = 2;
subplot (2, 1, 2);
stem (n, s*x, ‘filled’);
title (‘Amplitude scaling signal’);
ylabel (‘Amplitude’);
axis ([1 7 0 4]);
axis ([1 7 0 4]);
axis ([1 7 0 8]);
Signum Signal
t = -5:0.1:5;
signum_signal = sign(t);
plot(t, signum_signal, 'LineWidth', 2);
xlabel('t');
ylabel('sgn(t)');
title('Signum Signal');
grid on;
ylim([-1.5 1.5]);

Signum Signal (Manually Implemented)

t = -5:0.1:5;
signum_signal = zeros(size(t));
for i = 1:length(t)
if t(i) > 0
signum_signal(i) = 1;
elseif t(i) < 0
signum_signal(i) = -1;
else
signum_signal(i) = 0;
end
end
plot(t, signum_signal, 'LineWidth', 2);
xlabel('Time (t)');
ylabel('x(t)');
title('Signum Signal (Manually Implemented)');
grid on;
Triangle Signal
f = 1;
t = 0:0.001:2;
triangle_wave = sawtooth(2 * pi * f * t, 0.5);
plot(t, triangle_wave, 'LineWidth', 2);
xlabel('Time (t)');
ylabel('Amplitude');
title('Triangle Signal');
grid on;
ylim([-1.5 1.5]);

Triangle Signal(Manually Implemented)


T = 4;
t = 0:0.01:8;
A = 1;
triangle_signal = zeros(size(t));
for i = 1:length(t)
mod_t = mod(t(i), T);
if mod_t < T/2
triangle_signal(i) = (2*A/T) * mod_t;
else
triangle_signal(i) = (2*A/T) * (T - mod_t);
end
end
plot(t, triangle_signal, 'LineWidth', 2);
xlabel('Time (t)');
ylabel('Amplitude');
title('Triangle Signal (Manually Implemented)');
grid on;
Exponential Signal
A = 1;
alpha = -0.5;
t = -5:0.01:5;
x = A * exp(alpha * t);
plot(t, x, 'LineWidth', 2);
xlabel('Time (t)');
ylabel('x(t) = A * e^{\alpha t}');
title('Exponential Signal');
grid on;

Corrected Parabolic Signal


A = 1;
t = -5:0.1:5;
parabolic_signal = A * (t.^2) / 2;
plot(t, parabolic_signal, 'LineWidth', 2);
xlabel('Time (t)');
ylabel('x(t) = A * t^2 / 2');
title('Corrected Parabolic Signal');
grid on;

You might also like