Borrar filtros
Borrar filtros

Info

La pregunta está cerrada. Vuélvala a abrir para editarla o responderla.

Subscript indices must either be real positive integers or logicals

1 visualización (últimos 30 días)
Abdulaziz
Abdulaziz el 12 de Dic. de 2011
Cerrada: MATLAB Answer Bot el 20 de Ag. de 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 comentario
Walter Roberson
Walter Roberson el 12 de Dic. de 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 ?

Respuestas (1)

Andrei Bobrov
Andrei Bobrov el 12 de Dic. de 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*')

La pregunta está cerrada.

Etiquetas

Aún no se han introducido etiquetas.

Community Treasure Hunt

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

Start Hunting!

Translated by