Code for generating FSK signal using MATLAB!
x=input('input binary message sequence');
N=length(x);
t=0.001:0.001:N;
for i=1:1:N;
m((i-1)*1000+1:i*1000)=x(i);
end
f1=10;
f2=5;
c1=2*sin(2*pi*f1*t);
y1=m.*c1;
for j=1:N
if x(j)==1
x(j)=0;
else
x(j)=1;
end
m1((j-1)*1000+1:j*1000)=x(j);
end
c2=2*sin(2*pi*f2*t);
y2=m1.*c2;
y=y1+y2;
subplot(3,1,1);
plot(t,m);
xlabel('Time');
ylabel('Amplitude');
Title('Bit sequence');
subplot(3,1,2);
plot(t,c1);
xlabel('Time');
ylabel('Amplitude');
Title('Carrier');
subplot(3,1,3);
plot(t,y);
xlabel('Time');
ylabel('Amplitude');
Title('Fsk signal');
Output:
Input sequence [1 0 0 1 1 1 0]
x=input('input binary message sequence');
N=length(x);
t=0.001:0.001:N;
for i=1:1:N;
m((i-1)*1000+1:i*1000)=x(i);
end
f1=10;
f2=5;
c1=2*sin(2*pi*f1*t);
y1=m.*c1;
for j=1:N
if x(j)==1
x(j)=0;
else
x(j)=1;
end
m1((j-1)*1000+1:j*1000)=x(j);
end
c2=2*sin(2*pi*f2*t);
y2=m1.*c2;
y=y1+y2;
subplot(3,1,1);
plot(t,m);
xlabel('Time');
ylabel('Amplitude');
Title('Bit sequence');
subplot(3,1,2);
plot(t,c1);
xlabel('Time');
ylabel('Amplitude');
Title('Carrier');
subplot(3,1,3);
plot(t,y);
xlabel('Time');
ylabel('Amplitude');
Title('Fsk signal');
Output:
Input sequence [1 0 0 1 1 1 0]
No comments:
Post a Comment