frequency = 1000;
timeperiod = 1/frequency;
amplitude = 1;
dcoffset = 0;
t=0:0.00001:2*timeperiod;
out=dcoffset+amplitude*cos(2*pi*frequency*t);
plot(t,out)
Tested on Octave 3.2.4: March - 25, 2011
%Requirement: For plotting 2 periods of the signal
fs = 100000; %100KHz sampling frequency
f = 1000; %1KHz signal frequency
t = 0:1/fs:2*(1/f);
x = sin(2*pi*f*t);
plot(t,x)
%Requirement: For getting 10 sec samples
fs = 100000; %100Khz sampling frequency
f = 2; % 2Hz signal frquency
t = 0:1/fs:10-1/fs; %10sec sampleshttp://www.blogger.com/img/blank.gif
x = sin(2*pi*f*t);
plot(t,x)
%Requirement: For getting 100 samples
fs = 500; %500Hz sampling frequency
f = 100;
t = (0:100-1)/fs;
x = sin(2*pi*f*t);
plot(t,x)
Matlab Tutorial link
No comments:
Post a Comment