Task 1
Plotting a sine curve
close all clear clc freq=input('Freqiuency of Sine function= '); amp=input('Amplitude of Function= '); phi=input('Initial Phase of Sine Function= '); time=input('End Time for Signal= '); fs=freq*10; %Following nyquist critereon t=0:1/fs:time; w=2*pi*freq; y=amp*sin(w*t+phi); figure(1) plot(t,y) figure(2) stem(t,y)
Task 2
Plotting a cosine curve
close all clear clc freq=input('Freqiuency of Cosine function= '); amp=input('Amplitude of Function= '); phi=input('Initial Phase of COsine Function= '); time=input('End Time for Signal= '); fs=freq*10; %Following nyquist critereon t=0:1/fs:time; w=2*pi*freq; y=amp*cos(w*t+phi); figure(1) plot(t,y) figure(2) stem(t,y)
Task 3
Combination of sine and cosine function
close all clear clc fs=1000; %sine part f1=2; phi1=0; a1=5; %cosine part f2=3; phi2=0; a2=5; t=0:1/fs:10; y1=a1*sin(2*pi*f1*t+phi1); y2=a2*cos(2*pi*f2*t+phi2); y=y1-y2; plot(t,y);
Task 4
Plotting Exponential Function
To be Done by students
Task 5
Generating a Unit Step function
close all clear clc fs=10; a=1; t=-20:1/fs:20; y=zeros(1,length(t)); for i=1:length(t) if t(i)>=0 y(i)=a; end end figure plot(t,y) ylim([0 2]) figure stem(t,y)
Homework
Will be assigned later