Index exceeds problem in line 19

조회 수: 1 (최근 30일)
Aiman Lutf
Aiman Lutf 2021년 3월 25일
답변: darova 2021년 3월 25일
clear all
close all
Nn=60;
Tn=0.5*10^-3;
B0=1*10^3;
Lambda=50; %(50,100)
Cn=10:40:300;
for i = 1:20
for n=1:20
%Dr(n)=Lambda*testQ;
Q1=Nn*Tn*B0*Cn(i)-Lambda+(log(Nn*Tn*B0))/2
Q2= log10(exp(1))*sqrt(Nn*Tn*B0)
Qf= qfunc(Q1/Q2)
Dr(n)=Lambda*(1- Qf)/(Nn*B0);
end
Dr_s(i)=sum(Dr(n));
end
figure;
plot(Cn,Dr_s)
grid on
I have a problem in line 19 with Q1, the message is index exceeds the number of array elements (8). can anyone help me with that.

답변 (2개)

DGM
DGM 2021년 3월 25일
It means exactly what it says. You've defined Cn as a 1x8 vector, then you are trying to reference its i-th element, where i is an index from 1-20. Cn does not have any more than 8 elements.

darova
darova 2021년 3월 25일
Cn uses index i
i loops through 1:20, but Cn has only 8 elements

카테고리

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

태그

제품

Community Treasure Hunt

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

Start Hunting!

Translated by