You are on page 1of 6

Revision of simple Functions and Operations

1.) Sine and Cosine Wave


%cos & sin wave
t=0:0.01:2;
x=sin(2*pi*t);
y=cos(2*pi*t);
plot(t,x);
hold on;
plot(t,y);
xlabel("time");
ylabel("amplitude");
title("Sin and Cos Wave");
grid on;

2.) Exponentially Growing


% exponential growing
t=-2:0.05:2;
a=0.5;
x=a*exp(t);
subplot(2,1,1);
plot(t,x);
xlabel("time");
ylabel("amplitude");
title("Exponential Growing");
grid on;
3.) Sinc Wave
%sinc wave
t=-2:0.03:2;
x=sinc(2*pi*t);
subplot(2,1,1);
plot(t,x);
xlabel("time");
ylabel("amplitude");
title("Sinc Wave");
grid on;

4.) Discrete Sine and Cosine


Wave
%discrete sin and cos wave discrete
t=0:0.05:2;
x=sin(2*pi*t);
subplot(2,1,1);
stem(t,x);
xlabel("time");
ylabel("amplitude");
title("Sin Wave");
grid on;
y=cos(2*pi*t);
subplot(2,1,2);
stem(t,y);
xlabel("time");
ylabel("amplitude");
title("Cos Wave");
grid on;
5.) Unit Step
%unit step
t=-1:0.1:5;
x=t>=0;
subplot(2,1,1);
plot(t,x);
xlabel("time");
ylabel("amplitude");
title("Unit Step");
grid on;
subplot(2,1,2);
stem(t,x);
xlabel("time");
ylabel("amplitude");
title("Unit Step Discrete");
grid on;

6.) Program of Sampling the signal

%sampling
clear all;
close all;
clc;
f=input('Enter the frequency :');
%T=1/f;
fs1=input('Enter the sampling frequency fs1 :');
fs2=input('Enter the sampling frequency fs2 :');
fs3=input('Enter the sampling frequency fs3 :');
t=0:0.1:50;
t1=0:1:50;
x=sin(2*3.14*f*t);
subplot(4,1,1);
plot(t,x);
xlabel('Time');
ylabel('Amplitude');
title('Continuous sine wave');
y=sin(2*3.14*f*t1/fs1);
subplot(4,1,2);
stem(t1,y,'r');
xlabel('Time');
ylabel('Amplitude');
title('Sampled at fs1');
y=sin(2*3.14*f*t1/fs2);
subplot(4,1,3);
stem(t1,y,'b');
xlabel('Time');
ylabel('Amplitude');
title('Sampled at fs2');
y=sin(2*3.14*f*t1/fs3);
subplot(4,1,4);
stem(t1,y,'g');
xlabel('Time');
ylabel('Amplitude');
title('Sampled at fs3');
7)

You might also like