Docsity

MATLAB Programs for Generating Signals and Sequences, Study notes of Analog Communication

Toggle sidebar
bg1
1.% Program to generate a ramp signal
clc;close all;clear all;
n=input('Enter the length of ramp sequence N = '); % Get the length
s=input(' Enter the slop of the ramp S = '); % Get the slop of the ramp
t=0:n-1;
plot(t,s*t);
ylabel ('Amplitude');
xlabel ('Time Index');
TITLE ('Ramp signal');
grid on
2.%Program to generate the exponential sequence & sinc function
clc;close all;clear all;
n=input('Enter the duration of the signal N = ');
a=input ('Enter the scaling factor a = ');
t=0:.1:n-1;
y=exp(a*t);
subplot(2,1,1)
plot(t,y);
ylabel ('Amplitude');
xlabel ('Time Index');
TITLE ('Exponential Signal');
grid on
x = linspace(-5,5);
y = sinc(x);
subplot(2,1,2);
plot(x,y);
xlabel('time');
ylabel('amplitude');
title('sinc function');
grid on
3. %program to generate sine wave and cosine wave
clc;close all;clear all;
t=0:.0001:1;
y=5*sin(2*pi*1*t);
subplot(2,1,1);
plot(t,y);
ylabel ('Amplitude');
xlabel ('Time Index');
TITLE ('Sine wave');
grid on;
t=0:.0001:1;
y=5*cos(2*pi*1*t);
subplot(2,1,2);
plot(t,y);
ylabel ('Amplitude');
xlabel ('Time Index');
TITLE ('cosine wave');
grid on

Partial preview of the text

Download MATLAB Programs for Generating Signals and Sequences and more Study notes Analog Communication in PDF only on Docsity!

1 .% Program to generate a ramp signal

clc;close all;clear all; n=input('Enter the length of ramp sequence N = '); % Get the length s=input(' Enter the slop of the ramp S = '); % Get the slop of the ramp t=0:n-1; plot(t,s*t); ylabel ('Amplitude'); xlabel ('Time Index'); TITLE ('Ramp signal'); grid on

2 .%Program to generate the exponential sequence & sinc function

clc;close all;clear all;

n=input('Enter the duration of the signal N = '); a=input ('Enter the scaling factor a = '); t=0:.1:n-1; y=exp(a*t); subplot(2,1,1) plot(t,y); ylabel ('Amplitude'); xlabel ('Time Index'); TITLE ('Exponential Signal'); grid on x = linspace(-5,5); y = sinc(x); subplot(2,1,2); plot(x,y); xlabel('time'); ylabel('amplitude'); title('sinc function'); grid on

3. %program to generate sine wave and cosine wave

clc;close all;clear all; t=0:.0001:1; y=5sin(2pi1t); subplot(2,1,1); plot(t,y); ylabel ('Amplitude'); xlabel ('Time Index'); TITLE ('Sine wave'); grid on; t=0:.0001:1; y=5cos(2pi1t); subplot(2,1,2); plot(t,y); ylabel ('Amplitude'); xlabel ('Time Index'); TITLE ('cosine wave'); grid on