0% found this document useful (0 votes)
81 views11 pages

Sine Wave of Frequency 100Hz

The document contains MATLAB code for generating and plotting various signals including: 1) A 100Hz sine wave 2) A sine wave and cosine wave at 100Hz plotted on the same graph 3) Continuous and discrete unit step signals

Uploaded by

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

Sine Wave of Frequency 100Hz

The document contains MATLAB code for generating and plotting various signals including: 1) A 100Hz sine wave 2) A sine wave and cosine wave at 100Hz plotted on the same graph 3) Continuous and discrete unit step signals

Uploaded by

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

1.

SINE WAVE OF FREQUENCY 100HZ

clc
clear all
close all
f=100;
T=1/100;
t=[0:0.00001:1/100];
y=sin(2*pi*100*t);
plot(t,y);
title('Sine wave');
xlabel('Time');
ylabel('Amplitude');
2.SINE WAVE AND COSINE WAVE
clc
clear all
close all
f=100;
T=1/100;
t=[0:0.00001:1/100];
y=sin(2*pi*100*t);
z=cos(2*pi*100*t);
plot(t,y);
hold on
plot(t,z);
stem(t,y)
title('Sine wave')
xlabel('Time')
ylabel('Amplitude')
legend('sine','cosine')
3. UNIT STEP SIGNAL(CONTINUOUS AND DISCERETE)

clc
clear all
close all
t=-2:0.001:2;
y=t>=0;
plot(t,y);
xlabel('Time');
ylabel('Unit Step
Signal');

clc
clear all
close all
t=-1:0.1:1;
y=t>=0;
stem(t,y);
xlabel('Time');
ylabel('Unit Step
Signal');
4. RAMP SIGNAL FUNCTION(CONTINUOUS AND DISCRETE)

clc
clear all
close all
t=[0:1:10];
cont = t;
disc = t;
plot(t,cont)
hold on
stem(t,disc)
grid on
title('Unit Ramp Signal')
xlabel('Time')
ylabel('Amplitude')
legend('CTS','DTS')
5. SIGNUM FUNCTION(CONTINUOUS AND DISCRETE)

clc
clear all
close all
t=[-1:0.1:1];
y=sign(t)
plot(t,y)
grid on
title('Signum
Function')
xlabel('Time')
ylabel('Amplitude')

clc
clear all
close all
t=[-1:0.1:1];
y=sign(t)
stem(t,y)
grid on
title('Signum
Function')
xlabel('Time')
ylabel('Amplitude')
6.RECTANGLE PULSE OF WIDTH 2 UNITS

clc
clear all
close all
t= -2:0.01:2;
y=rectangularPulse(t/2);
plot(t,y);
xlabel('Amplitude');
ylabel('Time');
legend('Rectangular pulse');
1. WRITE A MATLAB PROGRAM TO GENERATE THE PLOT
FOR THE SIGNAL
X(n) = u(n) – u(n-10)
X(t) = u(t) – u(t-10)

clc
clear all
close all
t=0:0.01:50;
k=t>=0;
l=t>=9;
plot(t,k-l)

clc
clear all
close all
t=0:2:100;
k=t>=0;
l=t>=9;
stem(t,k-l)
2. WRITE A PROGRAM TO COMPUTE CONVALUTION OF A
RECTANGLE SIGNAL WITH ITSELF [WIDTH = 10UNITS]

clc
clear all
close all
n= -15:15;
rect= [zeros(1,15) ones(1,10) zeros(1,6)];
subplot(413);
stem(n,rect);
AXIS([-15 15 0 2.5]);
title('Rectangular Pulse')
WRITE A MATLAB PROGRAM FOR DISCRETE TIME
CONVALUTION
X(n) = u(n) – u(n-6)
h(n) = u(n) – u(n-6)
clc
close all
clear all
x=input('Enter x: ')
h=input('Enter h: ')
m=length(x);
n=length(h);
Y=zeros(m+n+1)
for i=1:n+m+1
for j=1:m
if(i-j+1>0 && not(i-j+1>n))
Y(i)=Y(i)+x(j)*h(i-j+1);
else
end
end
end
Y
stem(Y);
ylabel('Y[n]');
xlabel('----->n');
title('Convolution of Two Signals without conv
function');

You might also like