Docsity
Docsity

Prepare for your exams
Prepare for your exams

Study with the several resources on Docsity


Earn points to download
Earn points to download

Earn points by helping other students or get them with a premium plan


Guidelines and tips
Guidelines and tips

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

Matlab code snippets for generating various signals, including a ramp signal, exponential sequence, sinc function, sine wave, and cosine wave. Each program takes user inputs for the length of the sequence, scaling factor, and time index, and generates the corresponding signal using matlab functions.

Typology: Study notes

2014/2015

Uploaded on 09/14/2015

shubham_sarkar
shubham_sarkar 🇮🇳

2 documents

1 / 1

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

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