写一段MATLAB来进行fsk仿真,并输出图像
时间: 2023-03-14 10:03:29 浏览: 65
我可以给你一段MATLAB代码,它可以用来模拟fsk,并输出图像。clc;
clear all;
M=4; %Modulation Order
fc=2; %carrier frequency
fs=16; %sampling frequency
t=0:1/fs:1;
bits=[1 0 1 0 0 1 0 1]; %information bits
symbol=2*bits-1; %symbol mapping
s_rate=1; %symbol rate
N=length(t);for i=1:1:length(bits)
bit_rate(i*s_rate)=(bits(i));
endx=1;
for i=1:1:length(bit_rate)
if bit_rate(i)==1
y(x:x+s_rate)=1;
x=x+s_rate+1;
else
y(x:x+s_rate)=-1;
x=x+s_rate+1;
end
endz=[];
for i=1:1:length(y)
z=[z y(i).*ones(1,fs/s_rate)];
endfsk=z.*cos(2*pi*fc*t);subplot(3,1,1);
plot(bits,'LineWidth',2);
title('Information Bits');
axis([0 length(bits) -2 2]);
grid on;subplot(3,1,2);
plot(bit_rate,'LineWidth',2);
title('Bit Rate');
axis([0 length(bit_rate) -2 2]);
grid on;subplot(3,1,3);
plot(t,fsk,'LineWidth',2);
title('Frequency Shift Keying signal');
axis([0 length(fsk)/fs -2 2]);
grid on;