matlab demos功能,关于“Matlab Demos”的学习和总结

这里总结了Matlab Demos下通信工具箱里面的examples,给出源代码和注释。

程序代码 (一):关于BPSK的Mente Carlo仿真

% -------------------------------------------------------------------------

% Matlab Demos                                                      No.1.1

% -------------------------------------------------------------------------

% Phase Shift Keying Simulation

% This demo shows how to simulate a basic Quarternary Phase Shift Keying

% (QPSK) communication link, and to generate empirical performance curves

% that can be compared to theoretical predictions.

% -------------------------------------------------------------------------

% 1. 两个函数的使用:rectpulse与intdump成对使用,重复插值与抽取,互为逆操作;

% 2. randn的seed的使用;

% 3. 这里的解调是直接采用MATLAB自带的pskmod、pskdemod函数;

% 4. 为什么在后面调用函数,当采用的EbNo越大的时候,计算需要的时间越长?甚至是

%    系统死机(大概超过10dB之后)?

% 5. 这里需要讨论的问题就是 Mente Carlo 仿真的数值问题,即当用一个试验样本函数去

%    估计一个观测值的时候,如何尽量减小估计值的方差问题(选择合适的仿真点总数和期望错误点数)。

% -------------------------------------------------------------------------

%                                       revised by lavabin  2006.07.26

% -------------------------------------------------------------------------

clc;clear all;close all;echo off;tic;

% -------------------------------------------------------------------------

%                      Parameter Definition

% -------------------------------------------------------------------------

nSamp = 8; numSymb = 100;

M = 4; SNR = 14;

seed = [12345 54321];

rand('state', seed(1)); randn('state', seed(2));

% -------------------------------------------------------------------------

%                Generating random information symbols

% -------------------------------------------------------------------------

numPlot = 10;

rand('state', seed(1));

msg_orig = randsrc(numSymb, 1, 0:M-1);

% -------------------------------------------------------------------------

% Phase modulating the data

% Use PSKMOD to phase modulate the data and RECTPULSE to upsample to a

% sampling rate 8 times the carrier frequency.

% -------------------------------------------------------------------------

grayencod = bitxor(0:M-1, floor((0:M-1)/2));

% Gray coding here!

% %  a = bitxor(0:M-1, floor((0:M-1)/2))

% %  a = 0     1     3     2

msg_gr_orig = grayencod(msg_orig+1);

% % Using "looktable" to map source data to Gray code

msg_tx = pskmod(msg_gr_orig,M);

% % Mapping source data to MPSK constellation

msg_tx = rectpulse(msg_tx,nSamp);

% -----------------------------

% figure(1);

% -----------------------------

scatterplot(msg_tx);

hold on;grid on;

% -------------------------------------------------------------------------

% Creating the noisy signal

% Then use AWGN to add noise to the transmitted signal to create the noisy

% signal at the receiver. Use the 'measured' option to add noise that is

% 14 dB below the average signal power (SNR = 14 dB). Plot the

% constellation of the received signal.

% -------------------------------------------------------------------------

randn('state', seed(2));

msg_rx = awgn(msg_tx, SNR, 'measured', [], 'dB');

% -----------------------------

% figure(2);

% -----------------------------

scatterplot(msg_rx);

hold on;grid on;

% -------------------------------------------------------------------------

% Recovering information from the transmitted signal

% Use INTDUMP to downsample to the original information rate. Then use

% PSKDEMOD to demodulate the signal, and detect the transmitted symbols.

% The detected symbols are plotted in red stems with circles and the

% transmitted symbols are plotted in blue stems with x's. The blue stems of

% the transmitted signal are shadowed by the red stems of the received

% signal. Therefore, comparing the blue x's with the red circles indicates

% that the received signal is identical to the transmitted signal.

% -------------------------------------------------------------------------

msg_rx_down  = intdump(msg_rx,nSamp);  % operation before DEMOD

msg_gr_demod = pskdemod(msg_rx_down,M);

[dummy graydecod] = sort(grayencod);

graydecod = graydecod - 1;

msg_demod = graydecod(msg_gr_demod+1)';

figure(3);

stem(0:numPlot-1, msg_orig(1:numPlot), 'bx'); hold on;

stem(0:numPlot-1, msg_demod(1:numPlot), 'ro'); hold off;

axis([ 0 numPlot -0.2 3.2]); xlabel('Time'); ylabel('Amplitude');

% -------------------------------------------------------------------------

% Comparing original message to demodulated message

% -------------------------------------------------------------------------

[errorBit ratioBit] = biterr(msg_orig, msg_demod, log2(M));

[errorSym ratioSym] = symerr(msg_orig, msg_demod);

% -------------------------------------------------------------------------

% Running simulation examples

% The next step executes an example file SIMBASEBANDEX, which is a complete

% sin of the modulated

% signal.mulation example for QPSK. It demonstrates how to create simulation

% drivers in MATLAB that plot the simulation results as they are generated.

% -------------------------------------------------------------------------

% Running the QPSK simulation example

% The green and magenta lines are the theoretical bit error rate (BER) and

% symbol error rate (SER) performance curves for QPSK, respectively. The

% example, SIMBASEBANDEX, plots the simulated BER and SER in red and blue

% lines, respectively. SIMBASEBANDEX uses PSKMOD and PSKDEMOD to simulate

% PSK at baseband using a complex envelope representation.

% -------------------------------------------------------------------------

% [MPSK_ratio, MPSK_errors] = simbasebandex_lavabin(0:2:10)

[MPSK_ratio, MPSK_errors] = simbasebandex_lavabin(0:.5:10)

% Note:这个函数simbasebandex_lavabin在整个script中只被调用了一次。

simulation_time = toc

% -------------------------------------------------------------------------

%                              End of Script

% -------------------------------------------------------------------------

displayEndOfDemoMessage(mfilename);

% ---------------------------------------

%                              Results

% ---------------------------------------

% % MPSK_ratio =

% %

% %     0.0776    0.1489

% %     0.0588    0.1139

% %     0.0373    0.0730

% %     0.0232    0.0456

% %     0.0122    0.0243

% %     0.0060    0.0120

% %     0.0024    0.0049

% %     0.0008    0.0015

% %     0.0002    0.0004

% %     0.0000    0.0001

% %     0.0000    0.0000

% %

% %

% % MPSK_errors =

% %

% %         3812        3660

% %         2890        2798

% %         1833        1794

% %         1138        1121

% %          601         596

% %          297         296

% %          120         120

% %           62          62

% %           61          61

% %           61          61

% %           61          61

% -------------------------------------------------------------------------

% Matlab Demos                                                      No.1.2

% -------------------------------------------------------------------------

% Phase Shift Keying Simulation

% -------------------------------------------------------------------------

% 注意:

% 1. 关于误码率计算的Matlab函数 berawgn;

% 2. 设置了仿真迭代次数、每次迭代中仿真的符号数;

% 3. 关于误码率 误符号率计算的Matlab函数 biterr symerr

% 4. 整个过程中都是Matlab子定义函数的调用,调制、解调、误码率与误符号率的理论值、

%    实测值都是这些函数完成的;

% 5. 实际的测试过程中,加WGN的时候,使用的是EsNo的!因为输入的源为调制后的

%    QPSK符号。

% 6. 每个EbNo点上仿真结束的条件是 错误的符号数目达到expSymErrs 或者 完成全部的迭代

%    这样的结果是 对于EbNo很大的情况下,有可能在完全了全部的迭代次数之后,错误的符号数目

%    仍然没有达到expSymErrs,于是在这个EbNo点上继续进行下一次的迭代计算。这样对于EbNo

%    很大的情况下,自然要花费更多的时间!

% % 所以,针对这个问题,仿真的代码点总数和expSymErrs两者对BER分析都有直接的影响。

% % 这个结果是,在EbNo很小的时候,往往迭代次数还不够的时候,expSymErrs就已经达到了,因此不会

% % 进行更多的迭代操作,每次计算BER时候的总点数都是symbPerIter * iters,只是每次的错误符号数随之减少;

% % 而在EbNo很大的时候,则是等待错误数大于expSymErrs的条件产生,因此总点数在不断增加。

% % 从上面的分析,我们可以预期在设置不同的expSymErrs、symbPerIter、iters时,分别会对

% % BER的估计产生什么样的后果。

% -------------------------------------------------------------------------

%                                       revised by lavabin  2006.07.26

% -------------------------------------------------------------------------

function [ratio, errors] = simbasebandex_lavabin(EbNo)

% Baseband QPSK simulation example

%

%   [RATIO, ERRORS] = SIMBASEBANDEX(EbNo) demonstrates how to simulate

%   modulation using a complex baseband equivalent representation of the

%   signal modulated on a carrier. It also demonstrates demodulation and

%   detection of the signal in the presence of additive white Gaussian

%   noise for quaternary phase shift keying (QPSK). EbNo is a vector that

%   contains the signal to noise ratios per bit of the channels for the

%   simulation. This file runs a simulation at each of the EbNo's listed.

%   Each simulation runs until both the minimum simulation iterations have

%   been completed and the number of errors equals or exceeds 'expSymErrs'

%   (60 symbols). SIMBASEBANDEX then plots the theoretical curves for QPSK

%   along with the simulation results as they are generated.

%

%   SIMBASEBANDEX can be changed to simulate binary PSK (BPSK) by changing

%   M from 4 to 2. Changes to other modulations (i.e. modulation type and

%   alphabet) will require changes to the equations that generate expected

%   results.

% the minimum simulation iterations 最少的仿真迭代次数

% Define alphabet (quaternary), EsNo

% Change M to 2 for BPSK instead of QPSK

M = 4; k = log2(M); EsNo = EbNo + 10*log10(k);  % in dB

% Set number of symbols per iteration, number of iterations,

% and expected number of symbol error count

symbPerIter = 1024*4; iters = 6; expSymErrs = 60;

% symbPerIter = 1024*4; iters = 6; expSymErrs = 30;

% Set random number seeds for uniform and Gaussian noise

rand('state', 123456789);  randn('state', 987654321);

% Calculate expected results only for QPSK for plotting later on

expBER = berawgn(EbNo, 'psk', 4, 'nondiff');

expSER = 1 - (1 - expBER) .^ k;

% % BERAWGN Bit error rate (BER) for uncoded AWGN channels.

% %     BER = BERAWGN(EbNo, MODTYPE, M) returns the BER for PAM or QAM over an

% %     uncoded AWGN channel with coherent demodulation.

% %     EbNo -- bit energy to noise power spectral density ratio (in dB)

% %     MODTYPE -- modulation type, either 'pam' or 'qam'

% %     M -- alphabet size, must be a positive integer power of 2

% % -----------------------------------------------------------------------

% %     BER = BERAWGN(EbNo, 'psk', M, DATAENC) returns the BER for coherently

% %     detected PSK over an uncoded AWGN channel.

% %     DATAENC -- 'diff' for differential data encoding,

% %                'nondiff' for nondifferential data encoding

% %------------------------------------------------------------------------

% %     BER = BERAWGN(EbNo, 'dpsk', M) returns the BER for DPSK over an uncoded

% %     AWGN channel.

% %------------------------------------------------------------------------

% %     BER = BERAWGN(EbNo, 'fsk', M, COHERENCE) returns the BER for orthogonal

% %     FSK over an uncoded AWGN channel.

% %     COHERENCE -- 'coherent' for coherent demodulation,

% %                  'noncoherent' for noncoherent demodulation

% %------------------------------------------------------------------------

% %     BER = BERAWGN(EbNo, 'msk', DATAENC) returns the BER of coherently

% %     detected MSK over an uncoded AWGN channel.

% %     DATAENC -- 'diff' for differential data encoding,

% %                'nondiff' for nondifferential data encoding

% %------------------------------------------------------------------------

% %     BERLB = BERAWGN(EbNo, 'cpfsk', M, MODINDEX, KMIN) returns a lower bound

% %     on the BER of CPFSK over an uncoded AWGN channel.

% %     MODINDEX -- modulation index

% %     KMIN -- number of paths having the minimum  distance

% %------------------------------------------------------------------------

% %     See also bercoding, berfading, bersync.

% %------------------------------------------------------------------------

% Plot the theoretical results for SER and BER.

figure;

semilogy(EbNo(:), expSER, 'g-', EbNo(:), expBER, 'm-');

legend('Theoretical SER','Theoretical BER',0);  grid on;

title('Performance of Baseband QPSK');

xlabel('EbNo (dB)');

ylabel('SER and BER');

hold on;

drawnow;

% Create Gray encoding and decoding arrays

grayencod = bitxor(0:M-1, floor((0:M-1)/2));

[dummy graydecod] = sort(grayencod); graydecod = graydecod - 1;

% Drive the simulation for each of the SNR values calculated above

for idx2 = 1:length(EsNo)

% Exit loop only when minimum number of iterations have completed and the

% number of errors exceeds 'expSymErrs'

idx = 1;

while ((idx <= iters) || (sum(errSym) <= expSymErrs))% || --> logical or

%     while (idx <= iters)

% Generate random numbers from in the range [0, M-1]

msg_orig = randsrc(symbPerIter, 1, 0:M-1);

% Gray encode symbols

msg_gr_orig = grayencod(msg_orig+1)';

% Digitally modulate the signal

msg_tx = pskmod(msg_gr_orig, M);

% Add Gaussian noise to the signal. The noise is calibrated using

% the 'measured' option.

msg_rx  = awgn(msg_tx, EsNo(idx2), 'measured', [], 'dB');

% Demodulate the signal

msg_gr_demod = pskdemod(msg_rx, M);

% Gray decode message

msg_demod = graydecod(msg_gr_demod+1)';

% Calculate bit error count, BER, symbol error count and SER,

% for this iteration.

[errBit(idx) ratBit(idx)] = biterr(msg_orig, msg_demod, k);

[errSym(idx) ratSym(idx)] = symerr(msg_orig, msg_demod);

% Increment for next iteration

idx = idx + 1;

end

% average the errors and error ratios for the iterations.

errors(idx2, :) = [sum(errBit),  sum(errSym)];

ratio(idx2, :)  = [mean(ratBit), mean(ratSym)];

% %     函数说明 mean:

% %      MEAN   Average or mean value.

% %     For vectors, MEAN(X) is the mean value of the elements in X. For

% %     matrices, MEAN(X) is a row vector containing the mean value of

% %     each column.

% Plot the simulated results for SER and BER.

semilogy(EbNo(1:size(ratio(:,2),1)), ratio(:,2), 'bo', ...

EbNo(1:size(ratio(:,1),1)), ratio(:,1), 'ro');

legend('Theoretical SER','Theoretical BER','Simulated SER','Simulated BER',0);

drawnow;

end

hold off;

% -------------------------------------------------------------------------

%                              End of Function

% -------------------------------------------------------------------------

% % 函数说明:

% % DRAWNOW Flush pending graphics events.

% %     DRAWNOW "flushes the event queue" and forces MATLAB to

% %     update the screen.

% %

% %     There are four events that cause MATLAB to flush the event

% %     queue and draw the screen:

% %

% %     - a return to the MATLAB prompt

% %     - hitting a PAUSE statement

% %     - executing a GETFRAME command

% %     - executing a DRAWNOW command

程序代码 (二):

程序代码 (三):  关于升余弦滤波器

% -------------------------------------------------------------------------

%  Matlab Demos                                                      No.3.1

% -------------------------------------------------------------------------

%  Raised Cosine Filtering

% -------------------------------------------------------------------------

% (1)

% This demonstration uses the Communications Toolbox functions, RCOSINE and

% RCOSFLT, to demonstrate the ISI rejection capability of the raised cosine

% filter.

% (2)

% It demonstrates how to use RCOSINE and RCOSFLT, how the raised cosine

% filter controls intersymbol interference, and how to split

% the raised cosine filtering between transmitter and receiver.

% (3)

% This data sequence represents a digital sequence that will be upsampled by

% zero-padding before filtering.  Raised cosine filters will be used to shape

% the waveform without introducing intersymbol interference (ISI).

% -------------------------------------------------------------------------

% 几点主要的意思:

% 1   “升余弦函数 rcosine” 和 “升余弦滤波器函数 rcosflt”的使用;

% 2   波形成形的目标是在源端就利用升余弦函数的抗ISI特性消除ISI,因为不可能生成

%     绝对的的时域有限的信号;

% 3   升余弦滤波器在源/宿端的分割。

% % 从上到下几个code板块依次讨论了:

% % Delay的影响

% % R的影响

% % 发、收端之间平方根升余弦滤波

% % 缺省方式下的rcosflt的快速调用方法

% -------------------------------------------------------------------------

%                                       revised by lavabin  2006.08.02

% -------------------------------------------------------------------------

clc;clear all;close all;echo off;tic;

% -------------------------------------------------------------------------

%                      Parameter Definition

% -------------------------------------------------------------------------

Delay = 3; DataL = 20; R = .5; Fd = 1;Fs = 8; PropD = 0;

% Generate random data.

x = randsrc(DataL, 1, [], 1245);

% at time 0, 1/Fd, 2/Fd, ...

% Fd is the sampling frequency of the data source

% 1/Fd is the symbol period of the data source

tx = [PropD: PropD + DataL - 1] ./ Fd;

% figure(1)

stem(tx, x, 'kx');

axis([0 30 -1.6 1.6]); xlabel('Time'); ylabel('Amplitude');

% -------------------------------------------------------------------------

% RCOSFLT is used to upsample and filter the data stream using the filter

% designed by RCOSINE.  The plot compares the digital data and the upsampled,

% filtered signal.  It is difficult to compare the two signals because the peak

% response of the filter is delayed by the group delay of the filter

% (order/(2*Fs)).

% -------------------------------------------------------------------------

%  RCOSINE Design raised cosine filter.

%     NUM = RCOSINE(Fd, Fs) designs an FIR raised cosine filter to filter a

%     digital signal with the digital transfer sampling frequency Fd. The

%     filter sampling frequency is Fs. Fs/Fd must be a positive integer.

%   The default rolloff factor is 0.5, and the default filter delay

%   is 3/Fd seconds.

%

%   [NUM, DEN] = RCOSINE(Fd, Fs, TYPE_FLAG) gives specific filter design

%     instructions. TYPE_FLAG can be 'iir', 'sqrt', or a combination

%     such as 'iir/sqrt'. The order of the arguments is not important.

%       'fir'    Design FIR raised cosine filter (default).

%       'iir'    Design an IIR approximation to the FIR raised cosine filter.

%       'normal' Design the regular raised cosine filter (default).

%       'sqrt'   Design square root raised cosine filter.

%       'default' Use the default (FIR, Normal raised cosine filter).

%

%     [NUM, DEN] = RCOSINE(Fd, Fs, TYPE_FLAG, R) specifies the

%     rolloff factor in R, which is a real number in the range [0, 1].

%

%     [NUM, DEN] = RCOSINE(Fd, Fs, TYPE_FLAG, R, DELAY) specifies the filter

%   delay in DELAY, which must be a positive integer. DELAY/Fd is the

%   filter delay in seconds.

%

%     [NUM, DEN] = RCOSINE(Fd, Fs, TYPE_FLAG, R, DELAY, TOL) specifies the

%     tolerance in TOL for IIR filter design. The default value is 0.01.

%

%     When the designed filter is an FIR filter, the output in DEN is 1.

% -------------------------------------------------------------------------

% Design filter.

[yf, tf] = rcosine(Fd, Fs, 'fir', R, Delay);

% Upsample and filter.

[yo, to] = rcosflt(x, Fd, Fs, 'filter', yf);

% figure(2)

stem(tx, x, 'kx'); hold on;

plot(to, yo, 'b.'); hold off;

axis([0 30 -1.6 1.6]);  xlabel('Time'); ylabel('Amplitude');

% -------------------------------------------------------------------------

% This step compensates for the raised cosine filter group delay by delaying the

% input signal.  Now it is easy to see how the raised cosine filter upsamples

% and filters the signal.  The filtered signal is identical to the delayed input

% signal at the input sample times.  This demonstrates the raised cosine filter

% capability to band-limit the signal while avoiding ISI.

% -------------------------------------------------------------------------

% Correct for propagation delay

PropD = Delay * Fd;

% at time 0, 1/Fd, 2/Fd, ...

tx = [PropD: PropD + DataL - 1] ./ Fd;

% figure(2)

% figure1 与 figure2的波形对比强烈地反映出了Delay的作用,滤波器输出的波形与输入

% 波形在包络上的相似性需要通过延迟输入信号来得到保证

figure;

stem(tx, x, 'kx'); hold on;

plot(to, yo, 'b.'); hold off;

axis([0 30 -1.6 1.6]);  xlabel('Time'); ylabel('Amplitude');

% -------------------------------------------------------------------------

% This step demonstrates the effect that changing the rolloff factor from .5

% (blue curve) to .2 (red curve) has on the resulting filtered output.  The

% lower value for rolloff causes the filter to have a narrower transition band

% causing the filtered signal overshoot to be greater for the red curve than for

% the blue curve.

% ------------------------------------------------------------------------

% Design filter.

[yg, tg] = rcosine(Fd, Fs, 'fir', .2, Delay);

% Filter data.

[yo1, to1] = rcosflt(x, Fd, Fs, 'normal/fir/filter',yg);

% figure(3)

figure;

stem(tx, x, 'kx'); hold on;

% Plot filtered data.

plot(to, yo, 'b-',to1, yo1, 'r-'); hold off;

% Set axes and labels.

axis([0 30 -1.6 1.6]);  xlabel('Time'); ylabel('Amplitude');

legend('Source Data','R = 0.5','R = 0.2')

% -------------------------------------------------------------------------

% A typical use of raised cosine filtering is to split the filtering between

% transmitter and receiver.  The data stream is upsampled and filtered at the

% transmitter using the square-root raised cosine filter.  This plot shows

% the transmitted signal when filtered using the square-root raised cosine

% filter.  The "fir/sqrt" switch was used with RCOSINE to generate the

% square-root raised cosine filter.

% -------------------------------------------------------------------------

% Design square root filter.

[ys, ts] = rcosine(Fd, Fs, 'fir/sqrt', R, Delay);

% Filter at the transmitter.

[yc, tc] = rcosflt(x, Fd, Fs, 'filter', ys);

% figure(4)

figure;

stem(tx, x, 'kx'); hold on;

plot(tc, yc, 'm.'); hold off;

axis([0 30 -1.6 1.6]);  xlabel('Time'); ylabel('Amplitude');

% -------------------------------------------------------------------------

% The transmitted signal (magenta curve) is then filtered, but not upsampled, at

% the receiver, using the same square-root raised cosine filter, resulting in a

% signal depicted by the blue curve at the receiver.  The resulting signal is

% virtually identical to the signal filtered using a single raised cosine

% filter.  The "Fs" was used to filter without upsampling.

% -------------------------------------------------------------------------

% Filter at the receiver.

[yr, tr] = rcosflt(yc, Fd, Fs, 'filter/Fs', ys);

% Adjust for propagation delay.

tcc = tc + Delay .* Fd;  txx = tx + Delay .* Fd;

% figure(5)

figure;

stem(txx, x, 'kx'); hold on;

plot(tcc, yc, 'm-',tr, yr, 'b-'); hold off;

axis([0 30 -1.6 1.6]);  xlabel('Time'); ylabel('Amplitude');

% -------------------------------------------------------------------------

% This step demonstrates a quicker way to filter data using RCOSFLT.  When

% RCOSFLT is used without the "filter" type switch, it designs a filter and uses

% it to filter the input data.  This step creates the same plot as before but

% designs the raised cosine filter and generates the filtered stream in one

% command.

% -------------------------------------------------------------------------

% Design and filter.

[yo2, to2] = rcosflt(x, Fd, Fs, 'normal/fir', R, Delay);

% figure(6)

figure;

stem(tx, x, 'kx'); hold on;

plot(to2, yo2, 'b-'); hold off;

axis([0 30 -1.6 1.6]);  xlabel('Time'); ylabel('Amplitude');

% -------------------------------------------------------------------------

displayEndOfDemoMessage(mfilename)

% -------------------------------------------------------------------------

simulation_time = toc

% -------------------------------------------------------------------------

%                              End of Script

% -------------------------------------------------------------------------

% % 关于rcosflt的函数说明

% -------------------------------------------------------------------------

% % RCOSFLT Filter the input signal using a raised cosine filter.

% %     Y = RCOSFLT(X, Fd, Fs, TYPE_FLAG, R, DELAY) filters the input signal X

% %     using a raised cosine FIR filter. The sample frequency for the input, X,

% %     is Fd (Hz).  The sample frequency for the output, Y, is Fs (Hz).  Fs must be

% %     an integer multiple of Fd.  The TYPE_FLAG gives specific filter design

% %     or filtering options.  The rolloff factor, R, determines the width of the

% %     transition band of the filter.  DELAY is the time delay from the beginning

% %     of the filter to the peak of the impulse response.

% %

% %     R, the rolloff factor specifies the excess bandwidth of the filter.  R must

% %     be in the range [0, 1]. For example, R = .5 means that the bandwidth of the

% %     filter is 1.5 times the input sampling frequency, Fd.  This also means that

% %     the transition band of the filter extends from .5 * Fd and 1.5 * Fd.  Since

% %     R is normalized to the input sampling frequency, Fd, it has no units.

% %     Typical values for R are between 0.2 to 0.5.

% %

% %     DELAY determines the group delay of the filter.  The group delay is the

% %     opposite of the change in filter phase with respect to frequency.  For linear

% %     phase filters, the group delay is also the time delay between the input

% %     signal and the peak response of the filter.  DELAY also determines the

% %     length of the filter impulse response used to filter X.  This delay is

% %         Fs/Fd * (2 * DELAY + 1).

% %

% %     Y is the output of the upsampled, filtered input stream X.  The length of

% %     vector Y is

% %         Fs/Fd * (length(X) + 2 * DELAY).

% %

% %     TYPE_FLAG is a string which may contain any of the option strings listed

% %     below delimited by a '/'  For example, the 'iir' and 'Fs' flags may

% %     be combined as 'iir/Fs'.  While some of the pairs of option substrings

% %     are mutually exclusive, they are not mutually exclusive in general.

% %

% %     'fir'    Design an FIR filter and use it to filter X.  When the 'filter'

% %              TYPE_FLAG is not used, an FIR filter is designed and used to

% %              filter X.  See the 'filter' TYPE_FLAG description for the behavior

% %              when the 'fir' and 'filter' TYPE_FLAGs are used together.  This

% %              option is exclusive of the 'iir' substring.

% %

% %     'iir'    Design an IIR filter and use it to filter X.  When the 'filter'

% %              TYPE_FLAG is not used, an IIR approximation to the equivalent FIR

% %              filter is designed and used to filter X.  See the 'filter'

% %              TYPE_FLAG description for the behavior when the 'iir' and 'filter'

% %              TYPE_FLAGs are used together.  This option is exclusive of the

% %              'fir' substring.

% %

% %     'normal' Design a normal raised cosine filter and use it to filter X.  The

% %              filter coefficients are normalized so the peak coefficient is one.

% %              This option is exclusive of the 'sqrt' substring.

% %

% %     'sqrt'   Design a square root raised cosine filter and use it to filter X.

% %              The filter coefficients are normalized so that the impulse

% %              response of this filter when convolved with itself will result

% %              in an impulse response that is approximately equal to the 'normal'

% %              raised cosine filter.  The difference in this approximation is due

% %              to finite filter length.  This is a useful option when the raised

% %              cosine filtering is split between transmitter and receiver by

% %              using the 'sqrt' filter in each device. This option is exclusive

% %              of the 'normal' substring.

% %

% %     'Fs'     X is input with sample frequency Fs (i.e., the input signal has

% %              Fs/Fd samples per symbol). In this case the input signal is not

% %              upsampled from Fd to Fs but is simply filtered by the raised

% %              cosine filter.  This is useful for filtering an oversampled data

% %              stream at the receiver.  When using the 'Fs' substring, the length

% %              of vector, Y is

% %                 length(X) + Fs/Fd * 2 * DELAY.

% %

% %     'filter' Means the filter is provided by the user.  When using the 'filter'

% %              TYPE_FLAG, the input parameters are:

% %

% %              Y = RCOSFLT(X, Fd, Fs, TYPE_FLAG, NUM) - filters with a user-

% %              supplied FIR filter.  When the TYPE_FLAG contains 'filter' and

% %              the 'fir' type substrings, the FIR filter indicated by NUM is

% %              used to filter X.

% %

% %              Y = RCOSFLT(X, Fd, Fs, TYPE_FLAG, NUM, DEN, DELAY) - filters with

% %              a user-supplied IIR filter.  When TYPE_FLAG contains both 'filter'

% %              and 'iir' type substrings, the IIR filter defined by numerator,

% %              NUM, and denominator, DEN, is used as to filter X.  The DELAY

% %              parameter is used to force RCOSFLT to behave as if the filter were

% %              designed by RCOSFLT using the same DELAY parameter.  The DELAY

% %              parameter should match the DELAY parameter used to design the

% %              filter defined by NUM and DEN in the RCOSINE function.  The default

% %              value of DELAY is 3.

% %

% %              The raised cosine filter should be designed using the RCOSINE

% %              function.

% %

% %     Y = RCOSFLT(X, Fd, Fs, TYPE_FLAG, R) filters the input signal X

% %     using a raised cosine filter and default DELAY parameter, 3.

% %

% %     Y = RCOSFLT(X, Fd, Fs, TYPE_FLAG) filters the input signal X using a

% %     raised cosine filter and the following default parameters

% %         DELAY = 3

% %         R = .5

% %

% %     Y = RCOSFLT(X, Fd, Fs) filters the input signal X using a raised cosine

% %     filter and the following default parameters

% %         DELAY = 3

% %         R = .5

% %         TYPE_FLAG = 'fir/normal'

% %

% %     Y = RCOSFLT(X, Fd, Fs, TYPE_FLAG, R, DELAY, TOL) specifies the

% %     tolerance in IIR filter design. The default value for TOL is .01.

% %

% %     [Y, T] = RCOSFLT(...) returns the time vector in T.

% -------------------------------------------------------------------------

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值