% sine100hz.m generate 100 Hz sine wave with sampling rate fs=1/Ts
clear;
f=1000; % frequency of wave
time = 0.1; % total time in seconds
Ts = 1/10000; % sampling interval
t = Ts:Ts:time; % define a "time" vector
tmp = rand(1,10);
for n=1:10
if(tmp(n)>0.5)
tmp1(n) = 1;
else
tmp1(n) = -1;
end
end
for i=1:10
for j=1:100
band((i-1)*100+j) = tmp1(i);
end
end
w=sin(2*pi*f*t); % define the sine wave
v = w.*band;
nco = sin(2*pi*(f+20)*t + pi*0/180);
r = v.*nco;
figure(1);
subplot(4,1,1)
plot(t,band); % plot the sine vs. time
xlabel('seconds') % label the x axis
subplot(4,1,2)
plot(t,w); % plot the sine vs. time
xlabel('seconds') % label the x axis
subplot(4,1,3)
plot(t,v); % plot the sine vs. time
xlabel('seconds') % label the x axis
subplot(4,1,4)
plot(t,r); % plot the sine vs. time
xlabel('seconds') % label the x axis