How can i rectify this error "Subscripted assignment dimension mismatch."

clc
clear all
nCP = 8; %round(Tcp/Ts);
nFFT = 64;
NT = nFFT + nCP;
F = dftmtx(nFFT)/sqrt(nFFT);
MC = 1500;
EsNodB = 0:5:40;
snr = 10.^(EsNodB/10);
beta = 17/9;
M = 16;
modObj = modem.qammod(M);
demodObj = modem.qamdemod(M);
L = 5;
N=5;
ChEstLS = zeros(1,length(EsNodB));
for ii = 1:length(EsNodB)
disp('EsN0dB is :'); disp(EsNodB(ii)); tic;
ChMSE_SVD=0;
g2 = randn(L,N)+1i*randn(L,N);
g = g2/norm(g2);
H = fft(g,nFFT);
X = randi([0 M-1],nFFT,5); %BPSK symbols
XD = modulate(modObj,X)/sqrt(10); % normalizing symbol power
Y = randi([0 M-1],nFFT,5); %BPSK symbols
HhatLS = Y./XD;
Rhh = H*H';
[U,S,V] = svd(Rhh);
p=8;
for k= 1:p-1;
lambdak=diag(S)
delk= lambdak/(lambdak+(beta/snr(ii)));
HhatSVD =U*delk*V*HhatLS;
%syms k
ChMSE_SVD= ChMSE_SVD + ((H -HhatSVD)'*(H-HhatSVD))/nFFT;
end
% for j=1:ii
% ChMSE_SVD=ChMSE_SVD1(:,j);
ChEstSVD(ii)=ChMSE_SVD/MC; % in this line i get an error
%end
toc;
end
% Channel estimation
semilogy(EsNodB,ChMSE_SVD,'b','LineWidth',2);
legend('SVD');

Answers (1)

You have
ChEstSVD(ii)=ChMSE_SVD/MC; % in this line i get an error
The right hand size, ChMSE_SVD, is a 5 x 5 array, and MC is a scalar, so ChMSE_SVD/MC will give a 5 x 5 result. You are attempting to store that 5 x 5 result into the single location ChEstSVD(ii)

5 Comments

i tried another method by extractring each column per iteration , but it shows another error "error in semilogy"
for j=1:5
ChMSE_SVD=ChMSE_SVD1(:,j);
%ChEstSVD = nan(1,ii);
ChEstSVD=ChMSE_SVD/MC;
end
This modification i made
You seem to be expecting that ChEstSVD will be a vector output, one output per column of ChMSE_SVD1 . However, you have not defined any way of transforming that column of data into a scalar.
Is it possible that you want one 5 different output lines in your plot? If so then define
ChEstSVD = ChMSE_SVD ./ MC;
with no loop.
by doing this way, i get an error in semilogy. figure appears on the screen but with no plot
Well, you can use
ChEstSVD(ii,:,:)=ChMSE_SVD/MC;
That will give you a length(EsNodB) by L by N matrix (9 x 5 x 5) to be plotted against X coordinates EsNodB (1 x 9). But now what?
Especially since all of those values are complex ? You are trying to plot the results of a SVD-type computation, but SVD-type calculations do not give scalar outputs (at best you can get a diagonal vector output, if you call svd() and take the second output.)
I also have to ask whether you are aware that when you compute
delk= lambdak/(lambdak+(beta/snr(ii)))
that because lambdak is a vector, you are doing algebraic matrix operations, with the 64 x 1 vector lambdak resulting in a 64 x 64 operation being returned as a least-squared fit because of the / fitting operation. The / operation is not an element-by-element division operator! And if you were to change the / to ./ to get element-by-element division then the U*delk*V operation that follows would fail. So maybe you do want the / operator -- but if so then I would recommend adding a comment describing the meaning of the line.
You might use abs() to convert the 9 x 5 x 5 array ChEstSVD to real values, but that would still leave you with the question of what it means to plot that.

Sign in to comment.

Categories

Tags

Asked:

on 29 Mar 2018

Commented:

on 30 Mar 2018

Community Treasure Hunt

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

Start Hunting!