目的:为了方便以后在32上实现字符串传输,采用for循环实现FSK调制
%
% %4FSK调制过程
f1 = 1;f2 = 2;f3 = 3;f4 = 4;
Fs=100;
t = 0:2*pi/100:2*pi-2*pi/100;%一个
m1 = [];%采样信号
c1 = [];%
b1 = [];%基带信号
ch='A';
N = length(ch)*4;
hex1=abs(ch);%由字符转化为对应的ASCII值
hex2=abs(ch);
for i = 1:N/4%
for j=1:4%一个unsigned char型变量,对应2个16进制数据,对应8个2进制数据
temp=mod(hex1(1,i),4);
hex1(1,i)=fix(hex1(1,i)/4);
if temp ==0
m = ones(1,100);
c = sin(f1*t);
b = zeros(1,100);
elseif temp ==1
m = ones(1,100);
c = sin(f2*t);
b = ones(1,100);
elseif temp ==2
m = ones(1,100);
c = sin(f3*t);
b = 2*ones(1,100);
else
m = ones(1,100);
c = sin(f4*t);
b = 3*ones(1,100);
end
m1 = [m1 m];
c1 = [c1 c];
b1 = [b1 b];
end
end
qfsk = m1.*c1;
subplot(2,1,1);
plot(b1);
title('原始信号');
axis([0 100*N -0.1 3.1]);
subplot(2,1,2);
plot(qfsk);
title('qfsk');
axis([0 100*N -3 3]);