필터 지우기
필터 지우기

Info

이 질문은 마감되었습니다. 편집하거나 답변을 올리려면 질문을 다시 여십시오.

Subscript indices must either be real positive integers or logicals

조회 수: 1 (최근 30일)
Abdulaziz
Abdulaziz 2011년 12월 12일
마감: MATLAB Answer Bot 2021년 8월 20일
When I run this script:
x=-3:.1:3;
Go=1000;
Bc=5;
Pin=@(x) 3*exp(-x.^2);
Ein(i)=quadgk(Pin,-inf,inf);
for i=1:length(x);
z=x(i);
Eo(i)=quadgk(Pin,-inf,z);
E(i)=Eo (i)/Ein(i);
G(i)=Go/(Go-(Go-1)*exp(-E(i)*0.1));
Pin=3*exp(-x(i)^2);
Pout(i)=Pin*G(i);
Phi(i)=-0.5*Bc*log(G(i))*pi/180;
Aout(i)=sqrt(Pout(i))*exp(i*Phi(i));
end
Aoutf=fftshift(fft(Aout,100000));
f=(-100000/2:(100000/2-1)).*1/(0.01*100000);
Poutf(i)=abs (Aoutf).^2;
plot(f,abs(Poutf),'-r*')
I faced this error:
Subscript indices must either be real positive integers or logicals
Please help me on that
  댓글 수: 1
Walter Roberson
Walter Roberson 2011년 12월 12일
It would help if you told us which line the problem is occurring on.
Note: you assign to Poutf(i) after the "for i" loop, and you do not have any other assignments to Poutf. Why do you make that subscripted assignment ?

답변 (1개)

Andrei Bobrov
Andrei Bobrov 2011년 12월 12일
try this is cod
x=-3:.1:3;
Go=1000;
Bc=5;
Pin=@(x)3*exp(-x.^2);
Ein = quadgk(Pin,-inf,inf);
Aout = zeros(size(x));
for i1=1:length(x);
z=x(i1);
E1=quadgk(Pin,-inf,z)/Ein;
G=Go/(Go-(Go-1)*exp(-E1*0.1));
Pout=Pin(z)*G;
Phi=-0.5*Bc*log(G)*pi/180;
Aout(i1)=sqrt(Pout)*exp(1i*Phi);
end
Aoutf=fftshift(fft(Aout,100000));
f = (-100000/2:(100000/2-1)).*1/(0.01*100000);
Poutf = abs (Aoutf).^2;
plot(f,abs(Poutf),'-r*')

이 질문은 마감되었습니다.

태그

아직 태그를 입력하지 않았습니다.

Community Treasure Hunt

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

Start Hunting!

Translated by