【问题标题】:Dimension 1 is fixed on the left-hand side but varies on the right ([84480 x 1] in Matlab维度 1 固定在左侧,但在右侧变化(Matlab 中的 [84480 x 1]
【发布时间】:2019-05-23 16:55:34
【问题描述】:

我需要更正这段代码,上面写着“维度 1 固定在左侧,但在右侧有所不同([84480 x 1]...”

我正在尝试使用定点转换器来转换此代码。但是,对于 rxWaveform,这个维度 1 的错误是固定在左侧的……

rxWaveform = rxWaveform(1+offset:end,:);
function rxWaveform = new_synch(rxWaveform,pssRef)

%PSSIndices = ltePSSIndices(enb);         % getting PSS indexes
%pssGrid = lteDLResourceGrid(enb);       % generate empty sub frame for PSS symbols
%pssGrid(PSSIndices) = ltePSS(enb);      % map PSS symbols into the subframe
%pssRef = lteOFDMModulate(enb,pssGrid); % generate PSS reference signal via LTE OFDM

% getting the lenghts of the received waveform and PSS reference signal

rxSize = size(rxWaveform,1);
pssSize = size(pssRef,1);

% performing correlation between received waveform and pss symbols
pssCorr = xcorr(rxWaveform,pssRef);  

% segmenting resultant vector to identify the first local maximum
pssCorr = pssCorr(rxSize - pssSize:rxSize + pssSize,:);

% extract the index of first local maximum, M is not useful here, just for
% the output result 
[M,index] = max((abs(pssCorr)));

%calculating offset using local maximum
offset = index - pssSize -1;  % subtracted from 1 due to shift in the 



rxWaveform = rxWaveform(1+offset:end,:);





end

【问题讨论】:

    标签: matlab dimensions fixed-point


    【解决方案1】:

    这里有两种可能的情况,但第二种情况更有意义

    案例1:只更新原始数组的一部分并返回整个数组rxWaveform

    替换 rxWaveform = rxWaveform(1+offset:end,:);
    为此 rxWaveform(1+offset:end,:) = rxWaveform(1+offset:end,:);

    • rxWaveform 大小比方说是90000 by 1
    • rxWaveform(1+offset:end,:) 大小为 84480 by 1

    显然这两个维度是不同的
    您正在做的是更新原始rxWaveform的一部分@
    因此,您还需要指定新部分位置,即左侧的(1+offset:end,:)


    案例2:只返回原始数组的一部分rxWaveform(1+offset:end,:)

    如果您只想返回部分而不是整个rxWaveform,只需更改函数输出名称,它不应该是rxWaveform,但它可以是任何变量名称,比如'output'

    代码如下

    function output = new_synch(rxWaveform,pssRef)
    
    %PSSIndices = ltePSSIndices(enb);         % getting PSS indexes
    %pssGrid = lteDLResourceGrid(enb);       % generate empty sub frame for PSS symbols
    %pssGrid(PSSIndices) = ltePSS(enb);      % map PSS symbols into the subframe
    %pssRef = lteOFDMModulate(enb,pssGrid); % generate PSS reference signal via LTE OFDM
    
    % getting the lenghts of the received waveform and PSS reference signal
    
    rxSize = size(rxWaveform,1);
    pssSize = size(pssRef,1);
    
    % performing correlation between received waveform and pss symbols
    pssCorr = xcorr(rxWaveform,pssRef);  
    
    % segmenting resultant vector to identify the first local maximum
    pssCorr = pssCorr(rxSize - pssSize:rxSize + pssSize,:);
    
    % extract the index of first local maximum, M is not useful here, just for
    % the output result 
    [M,index] = max((abs(pssCorr)));
    
    %calculating offset using local maximum
    offset = index - pssSize -1;  % subtracted from 1 due to shift in the 
    
    
    
    output = rxWaveform(1+offset:end,:);
    
    
    
    
    
    end
    

    【讨论】:

      猜你喜欢
      • 2012-07-30
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2010-12-17
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多