gpt4 book ai didi

matlab - 在信号中查找二进制数据序列

转载 作者:太空宇宙 更新时间:2023-11-03 20:30:36 24 4
gpt4 key购买 nike

这是我的目标:

我正在尝试寻找一种方法来搜索数据信号并找到(索引)已知的重复二进制数据序列所在的位置。然后,因为扩频码和解调已知,所以拔出数据对应的芯片读取。目前,我相信 xcorr 可以解决问题。

这是我的问题:

我似乎无法解释 xcorr 或 xcorr2 的结果来提供我正在寻找的东西。我在从我的 xcorr 函数的向量位置到我的时间向量的交叉引用时遇到问题,或者在使用 xcorr 正确识别我的数据序列时遇到问题,或者两者兼而有之。可能存在其他可能性。

我在哪里/我有什么:

我创建了一个随机 BPSK 信号,该信号由重复周期内感兴趣的数据序列和垃圾数据组成。我已经尝试使用 xcorr 处理它,这是我被困的地方。

这是我的代码:

%% Clear Variables

clc;
clear all, close all;

%% Create random data

nbits = 2^10;
ngarbage = 3*nbits;
data = randi([0,1],1,nbits);
garbage = randi([0,1],1,ngarbage);
stream = horzcat(data,garbage);

%% Convert from Unipolar to Bipolar Encoding

stream_b = 2*stream - 1;

%% Define Parameters

%%% Variable Parameters
nsamples = 20*nbits;
nseq = 5 %# Iterate stream nseq times
T = 10; %# Number of periods
Ts = 1; %# Symbol Duration
Es = Ts/2; %# Energy per Symbol
fc = 1e9; %# Carrier frequency

%%% Dependent Parameters
A = sqrt(2*Es/Ts); %# Amplitude of Carrier
omega = 2*pi*fc %# Frequency in radians
t = linspace(0,T,nsamples) %# Discrete time from 0 to T periods with nsamples samples
nspb = nsamples/length(stream) %# Number of samples per bit

%% Creating the BPSK Modulation
%# First we have to stretch the stream to fit the time vector. We can quickly do this using _
%# simple matrix manipulation.

% Replicate each bit nspb/nseq times
repStream_b = repmat(stream_b',1,nspb/nseq);

% Tranpose and replicate nseq times to be able to fill to t
modSig_proto = repmat(repStream_b',1,nseq);

% Tranpose column by column, then rearrange into a row vector
modSig = modSig_proto(:)';

%% The Carrier Wave

carrier = A*cos(omega*t);

%% Modulated Signal

sig = modSig.*carrier;

使用 XCORR

我使用 xcorr2() 来消除 xcorr 对不等向量的零填充效果。请参阅下面的评论以进行说明。

corr = abs(xcorr2(data,sig); %# pull the absolute correlation between data and sig
[val,ind] = sort(corr(:),'descend') %# sort the correlation data and assign values and indices
ind_max = ind(1:nseq); %# pull the nseq highest valued indices and send to ind_max

现在,我认为这应该可以得出数据和信号之间的五个最高相关性。对于流的每次迭代,这些应该对应于流中数据的结束位,因为我认为这是数据与 sig 最强烈交叉关联的地方,但事实并非如此。有时,最大值甚至连一条流的长度都没有。所以我在这里很困惑。

问题

在三部分问题中:

  1. 我错过了某个步骤吗?在这种情况下,我如何使用 xcorr 来查找 data 和 sig 最相关的位置?

  2. 我的整个方法错了吗?我不应该寻找最大相关性吗?

  3. 或者我应该从另一个角度来解决这个问题,id est,不使用 xcorr 而可能使用 filter 或其他功能?

最佳答案

您的整体方法很棒并且很有意义。您遇到的问题是您正在与垃圾数据建立一些实际的关联。我注意到您将所有的流转移到以零为中心,但没有对您的数据做同样的事情。如果您将数据归零,您的相关峰将得到更好的定义(至少在我尝试时有效)。

data = 2*data -1;

此外,我不建议使用简单排序来查找峰值。如果你有一个宽峰,这在有噪声的信号中尤其可能发生,你可能有两个高点彼此相邻。找到一个最大值,然后将那个点和几个邻居归零。然后重复你喜欢的次数。或者,如果您知道您的纪元有多长,则只需与一个纪元的数据进行关联,并在信号到达时对其进行迭代。

关于matlab - 在信号中查找二进制数据序列,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16179442/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com