Generate a Cosine signal and one unit step signal using MATLAB codes
close all,
clear all,
clc,
Fs=1000;
F = 2;
t=0:(1/Fs):1;
x = cos(2*pi*F*t);
scrsz = get(0,'ScreenSize');
Dim=0;
figure('Position',[scrsz(1)+Dim, scrsz(2)+Dim,scrsz(3)-20,scrsz(4)-100]);
subplot(2,1,1); plot(t,x);
s =strcat('Cosine Signal at Freq. = ',32,num2str(F),32,'Hzs and Sampling Freq. Fs = ',32,num2str(Fs),32,'Hzs');
title(s,'FontSize',20);
xlabel('Time (t)');
ylabel('--- x(t) --->');
grid on,
t = -1:(1/Fs):1;
unitstep = t>=0;
subplot(2,1,2);
plot(t,unitstep)
ylim([0 2]);
s =strcat('Unit Step Signal');
title(s,'FontSize',20);
xlabel('Time (t)');
ylabel('--- x(t) --->');
grid on,
Comments
Leave a comment