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');

回答(1 个)

Tasos
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.

类别

Help CenterFile Exchange 中查找有关 Matched Filter and Ambiguity Function 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by