Power of faded signal after selection combiner
1 次查看(过去 30 天)
显示 更早的评论
Hello,
I have written a MATLAB code which plots the power of faded signal after passing through selection combiner. For this, I have created two independent Rayleigh faded signals and then used the concept of selection combiner. However, I am getting an error "Subscript indices must be real positive integers or logicals". I would deeply appreciate any help in this matter. Is there any syntax error or am I completely off the topic and my logic is flawed? Following is my code:
N=2000;
Ts = 1e-4; % Sample period (s)
fd = 100; % Maximum Doppler shift
%various channels
c1 = rayleighchan(Ts,fd); % Generate the channel fade
c2 = rayleighchan(Ts,fd);
sig = ones(2000,1); % Generate signal
y1 = filter(c1,sig);
y2 = filter(c2,sig);
%following code gives the dB values of faded signal
dbval1 = mag2db(abs(y1));
dbval2 = mag2db(abs(y2));
t = (0:N-1)'*Ts
plot(t,dbval1,'b');
ylabel('dB');
xlabel('Time');
hold on
plot(t,dbval2,'r');
for i = 0:N-1
if dbval1>dbval2
dbval3(i,:)= dbval1(i,:);
else
dbval3(i,:) = dbval2(i,:);
end
end
plot(t,dbval3, 'g');
0 个评论
回答(1 个)
Tasos
2018-3-3
The problem is exactly what the error message says. The indices to your vectors/matrices must start from 1 in Matlab not 0, e.g. i=1:N.
0 个评论
另请参阅
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!