How to generate broadband random signals using matlab

WBOY
Release: 2024-01-25 09:54:06
forward
517 people have browsed it

How to generate broadband random signals using matlab

How to use matlab to generate broadband random signals

Matlab Pseudo-random signal generation (M sequence)

There are two main methods explained here, one is to use m file editing, the other is to use simulink to generate

1. Edit with m file

Np=63;% cycle period

delta_T = 1; % clock ticks

a=1;% amplitude

%Initialize M sequence

M(1)=1;

M(2)=0;

M(3)=0;

M(4)=1;

M(5)=1;

M(6)=0;

M_XuLie(Np) = 0;

for n = 1 : Np

temp = xor(M(6), M(5));

if(temp == 0)

M_XuLie(n) = a;

else

M_XuLie(n) = -a;

end

M(6) = M(5);

M(5) = M(4);

M(4) = M(3);

M(3) = M(2);

M(2) = M(1);

M(1) = temp;

end

figure(4)

stairs(M_XuLie)

ylim([-2 2])

illustrate:

1. Principle: Since it is written in code, the expression of the principle may not be very intuitive. The principle will be given in the form of simulation later

2. Period: If there are N shift registers, then the period is 2^N-1

3. Continuation of cycle:

r = 3; % number of cycles

u=repmat(M_XuLie,1,r 1);%Assign the M sequence to the input as the input signal

2. Use simulink to generate M sequence

1 Choose 6 shift registers, which are 1/Z ones. Arrange them in order, and set the initial conditions to 1

2 First link these 6 shift registers, connect the first output to the second input, and so on until the sixth one is connected to OUT, and then connect a scope here to observe the signal waveform or connect it to the work space ( In this case, it is connected to the workspace). Set the variable name and output format as follows.

Note: Try to choose matrix form output, otherwise it will be inconvenient to call.

3 Select a logical operator and adjust it to XOR from the settings, 2 inputs

4 Continue to connect

5 Set parameters, mainly set the step size and total running time (click the menu simulation-configuration parameters settings)

6 Click to run. What is displayed in the scope is the m sequence! Or enter stairs(M_seque)

in the command line

Note: In fact, there are some problems in actual use with this method, that is, the output signal is of bool type, that is, a logical sequence, and cannot be used as the input of the transfer function. If it is in an m file, it can be passed through double Wait for the method to be converted. Simulink should have a method for conversion, but no relevant query has been made yet.

How to generate pn sequence in matlab

for k=1:length(x) gfpretty(x(k,:));end

mPseudo-random sequence Matlab source code

%5 order m sequence

% Enter the following in the MATLAB command window:

% fbconnection=[0 1 0 0 1];

% mseq="m"_sequence(fbconnection);

% mseq

function mseq="m"_sequence(fbconnection)

n=length(fbconnection);

N=2^n-1;

register=[ones(1,n-1) 1]; %The initial state of the shift register

mseq(1)=register(n); %mThe first output symbol of the sequence

for i="2:N"

newregister(1)=mod(sum(fbconnection.*register),2);

for j="2:n",

newregister(j)=register(j-1);

end;

register="newregister";

mseq(i)=register(n);

end

Save as m_sequence.m;

The above is the detailed content of How to generate broadband random signals using matlab. For more information, please follow other related articles on the PHP Chinese website!

source:docexcel.net
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!