example.m

来自「这是我师兄做的空间谱估计的内容。这只是一小部分程序」· M 代码 · 共 30 行

M
30
字号
clear;clc;
%set up parameters.
M=2;     %number of symbolsin alphabet.
len=100; %number of symbols in the original message.
Fd=1;    %assume the original message is sampled at a 
         %rate of 1 sample per second.
Fs=100;  %the modulated signal will be sampled at a 
         %rate of 100 samples per second.
Fc=10;   %the frequence of the modulated signal.
signal=randint(len,1,M);%random digital message consisting of 
                         %integers between 0 and M-1
%figure(1);stem(signal);
mp=modmap(signal,Fd,Fs,'ask',M);%map a digital signal to an analog signal
%figure(2);plot((1:len*Fs/Fd)/(Fs/Fd),mp);
%plot the analog signal
modsignal=dmod(mp,Fc,Fd,Fs,'ask/nomap',M);
%use M-ary ASK modulation
%figure(3);plot((1:len*Fs/Fd)/(Fs/Fd),modsignal);
%plot the modulated signal
%adding noise
noisy=modsignal+5*randn(len*Fs/Fd,1);
%demodulating the signal
newsignal=ddemod(noisy,Fc,Fd,Fs,'ask',M);
%figure(4);stem(newsignal);
%figure(5);stem(signal-newsignal)
%computing and displaying bit error rates
[num,rate]=biterr(newsignal,signal);
disp('-----------------------------------------')
disp('bit error rates:')
disp(num2str(rate))

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?