Index exceeds matrix dimensions ??

조회 수: 6 (최근 30일)
Ali
Ali 2011년 4월 1일
h = scatterplot(sqrt(nsamp)*ynoisy(1:nsamp*5e3),nsamp,0,'g.');
Index exceeds matrix dimensions ?? Error in ==> grd at 99 h = scatterplot(sqrt(nsamp)*ynoisy(1:nsamp*5e3),nsamp,0,'g.');
what is my problem? Just copy of :http://www.mathworks.com/help/toolbox/comm/ug/a1067963807.html#top_of_page

채택된 답변

Friedrich
Friedrich 2011년 4월 1일
Hi Ali,
please try to run the following code:
%%Setup
% Define parameters.
M = 16; % Size of signal constellation
k = log2(M); % Number of bits per symbol
n = 3e4; % Number of bits to process
nsamp = 1; % Oversampling rate
hMod = modem.qammod(M); % Create a 16-QAM modulator
%%Signal Source
% Create a binary data stream as a column vector.
x = randint(n,1); % Random binary data stream
% Plot first 40 bits in a stem plot.
stem(x(1:40),'filled');
title('Random Bits');
xlabel('Bit Index'); ylabel('Binary Value');
%%Bit-to-Symbol Mapping
% Convert the bits in x into k-bit symbols.
xsym = bi2de(reshape(x,k,length(x)/k).','left-msb');
%%Stem Plot of Symbols
% Plot first 10 symbols in a stem plot.
figure; % Create new figure window.
stem(xsym(1:10));
title('Random Symbols');
xlabel('Symbol Index'); ylabel('Integer Value');
%%Modulation
y = modulate(modem.qammod(M),xsym); % Modulate using 16-QAM.
%%Transmitted Signal
ytx = y;
%%Channel
% Send signal over an AWGN channel.
EbNo = 10; % In dB
snr = EbNo + 10*log10(k) - 10*log10(nsamp);
ynoisy = awgn(ytx,snr,'measured');
%%Received Signal
yrx = ynoisy;
%%Scatter Plot
% Create scatter plot of noisy signal and transmitted
% signal on the same axes.
h = scatterplot(yrx(1:nsamp*5e3),nsamp,0,'g.');
hold on;
scatterplot(ytx(1:5e3),1,0,'k*',h);
title('Received Signal');
legend('Received Signal','Signal Constellation');
axis([-5 5 -5 5]); % Set axis ranges.
hold off;
After you have run the code you should have the following variables in your workspace:
whos
Name Size Bytes Class Attributes
EbNo 1x1 8 double
M 1x1 8 double
h 1x1 8 double
hMod 1x1 modem.qammod
k 1x1 8 double
n 1x1 8 double
nsamp 1x1 8 double
snr 1x1 8 double
x 30000x1 240000 double
xsym 7500x1 60000 double
y 7500x1 120000 double complex
ynoisy 7500x1 120000 double complex
yrx 7500x1 120000 double complex
ytx 7500x1 120000 double complex
Please compare these values with yours in order to hunt down the issue.
I hope I could help,
Friedrich
  댓글 수: 1
Ali
Ali 2011년 4월 1일
Thanks I found my problem,
Is there anyway to calculate group delay?

댓글을 달려면 로그인하십시오.

추가 답변 (2개)

Andreas Goser
Andreas Goser 2011년 4월 1일
The link does not work for me, but when a code from a documentation example does not work, then it is likely that either the data has been altered. You can find out the cause of the issue by looking at the dimensions. What is "nsamp*5e" and is there an element ynoisy(1:nsamp*5e3)? Is that maybe an issue with the index being a DOUBLE?

Ali
Ali 2011년 4월 1일
http://www.mathworks.com/help/toolbox/comm/ug/a1067963807.html Copy and paste above link! I want to show how group delay filter work!

카테고리

Help CenterFile Exchange에서 Modulation에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by