You are on page 1of 1

s=input('enter the data sequence:' );

f1=input('enter the lower frequency:' );


f2=input('enter the higher frequency:' );
am=input('enter the amplitude:' );
U=s;
a=length(s);
U(a+1)=U(a);
for i=1:a
if s(i)==1
f=f1;
for t=(i-1)*100+1:i*100
x(t)=am*sin(2*pi*f*t/1000);
end
elseif s(i)==0
f=f2;
for t=(i-1)*100+1:i*100
x(t)=am*sin(2*pi*f*t/1000);
end
end
end
subplot(2,1,1);
stairs(U,'m');
axis([1 a+1 -2 2]);
xlabel('time');
ylabel('amplitude');
title('message signal');
grid on;
subplot(2,1,2);
plot(x,'b');
axis([1 a*100 -am am]);
xlabel('time');
ylabel('amplitude');
title('FSK');
grid on;
Output: enter the data sequence: [1 0 0 1 1 0]
enter the lower frequency: 10
enter the higher frequency: 50
enter the amplitude: 5

You might also like