Filter löschen
Filter löschen

Info

Diese Frage ist geschlossen. Öffnen Sie sie erneut, um sie zu bearbeiten oder zu beantworten.

Subscript indices must either be real positive integers or logicals

1 Ansicht (letzte 30 Tage)
Abdulaziz
Abdulaziz am 12 Dez. 2011
Geschlossen: MATLAB Answer Bot am 20 Aug. 2021
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 Kommentar
Walter Roberson
Walter Roberson am 12 Dez. 2011
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 ?

Antworten (1)

Andrei Bobrov
Andrei Bobrov am 12 Dez. 2011
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*')

Diese Frage ist geschlossen.

Tags

Noch keine Tags eingegeben.

Community Treasure Hunt

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

Start Hunting!

Translated by