Info
この質問は閉じられています。 編集または回答するには再度開いてください。
Subscript indices must either be real positive integers or logicals
1 回表示 (過去 30 日間)
古いコメントを表示
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
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
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*')
0 件のコメント
この質問は閉じられています。
参考
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!