asf.m
来自「通信中一些基本实验的程序AM、FM、ASK、FSK、PSK等等」· M 代码 · 共 42 行
M
42 行
h=round(rand(1,10));
hold off;
bit=[];
for n=1:2:length(h)-1;
if h(n)==0 & h(n+1)==1
se=[zeros(1,50) ones(1,50)];
elseif h(n)==0 & h(n+1)==0
se=[zeros(1,50) zeros(1,50)];
elseif h(n)==1 & h(n+1)==0
se=[ones(1,50) zeros(1,50)];
elseif h(n)==1 & h(n+1)==1
se=[ones(1,50) ones(1,50)];
end
bit=[bit se];
end
subplot(311)
t=1/500:1/500:1;
plot(t,bit,'LineWidth',1.5);grid on;
axis([0 1 -1.5 1.5]);
fc=30;
n=1;
tx=0:0.1/100:1;
a=sin(2*pi*fc*tx);
subplot(312)
plot(tx,a,'LineWidth',1.5);
subplot(313)
while n<=length(h)
if h(n)==1
tx=(n-1)*0.1:0.1/100:n*0.1;
p=(2)*sin(2*pi*fc*tx);
plot(tx,p,'LineWidth',1.5);grid on;
hold on;
else
tx=(n-1)*0.1:0.1/100:n*0.1;
p=(0)*sin(2*pi*fc*tx);
plot(tx,p,'LineWidth',1.5);grid on;
hold on;
end
n=n+1;
end
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?