Index exceeds matrix dimensions ??

3 ビュー (過去 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 Center および File ExchangeModulation についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by