sir,i am new to matlab . I received an error saying Index exceeds matrix dimensions..Here is the code for channelization.

1 visualización (últimos 30 días)
clc;
%DVB-T 2K Transmission
%The available bandwidth is 8 MHz
%2K is intended for mobile services
clear all;
close all;
%DVB-T Parameters
Tu=224e-6; %useful OFDM symbol period
T=Tu/2048; %baseband elementary period
G=0; %choice of 1/4, 1/8, 1/16, and 1/32
delta=G*Tu; %guard band duration
Ts=delta+Tu; %total OFDM symbol period
Kmax=2000; %number of subcarriers
Kmin=0;
FS=4096; %IFFT/FFT length
q=10; %carrier period to elementary period ratio
fc=q*1/T; %carrier frequency
Rs=4*fc; %simulation period
t=0:1/Rs:Tu;
%Data generator (A)
M=Kmax+1;
rand('state',0);
a=-1+2*round(rand(M,1)).'+i*(-1+2*round(rand(M,1))).';
A=length(a);
info=zeros(FS,1);
figure(1);
stem(a );
info(1:(A/2)) = [ a(1:(A/2)).']; %Zero padding
info((FS-((A/2)-1)):FS) = [ a(((A/2)+1):A).'];
%Subcarriers generation (B)
carriers=FS.*ifft(info,FS);
tt=0:T/2:Tu;
figure(2);
subplot(211);
stem(tt(1:400),real(carriers(1:400)));
title('subcar generation');
subplot(212);
stem(tt(1:400),imag(carriers(1:400)));
figure(3);
f=(1:(FS))/(FS);
subplot(211);
plot(f,abs(fft(carriers,FS)/FS));
figure(4);
l=length(abs(fft(carriers)));
w=hamming(l);
stem(w);
fs=4096/Tu;
df=1/Tu;
dalpha=2098/Tu;
x=carriers;
Np=pow2(nextpow2(fs/df));
L=Np/4;
P=pow2(nextpow2(fs/dalpha/L));
N=P*L;
% channelization
if length(x)<N
x(N)=0;
elseif length(x)>N
x=x(1:N);
end
NN=(P-1)*L+Np
xx=x
xx=xx(:)
p=ceil(P)
X=zeros(Np,ceil(p))
for k=0:p-1
X(:,k+1)=xx(k*L+1:k*L+Np);
end

Respuesta aceptada

Greg
Greg el 20 de En. de 2018
xx is length N = P*L. Inside the loop, the maximum iteration index is k*L+Np = (p-1)*L+4*L = (p+3)*L. Since p = ceil(P), (p+3)*L is guaranteed greater than P*L. Thus, your index into xx exceeds matrix dimensions.
The complete lack of structure in this code and variable naming makes this nearly impossible to decipher. You'd greatly benefit from spending a little effort to clean it up.

Más respuestas (0)

Categorías

Más información sobre Signal Reception and Recovery en Help Center y File Exchange.

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by