Matlab won't plot anything. please help why?

1 visualización (últimos 30 días)
Farooq
Farooq el 8 de Abr. de 2012
clear all;
clc;
u = 7 ;
snrdb = 5;
for pf=0.001:0.01:1;
lamda = 2*gammaincinv((1-pf),u);
gama = db2mag(snrdb);
p = 0:(u-2);
a = exp(-lamda/2);
b = ((1 + gama)/gama).^(u-1);
c = exp(-lamda/(2+2*gama));
x = sum((1./(factorial(p))).*((lamda/2).^p))
y = sum((1./(factorial(p))).*(((lamda*gama)/2*gama)).^p));
s=(a*x)+b.*(c-(a*y));
end
plot (pf,s);
grid on
  2 comentarios
Wayne King
Wayne King el 8 de Abr. de 2012
Please format your code example
Oleg Komarov
Oleg Komarov el 8 de Abr. de 2012
You're plotting one point not the entire sequence.

Iniciar sesión para comentar.

Respuesta aceptada

Oleg Komarov
Oleg Komarov el 8 de Abr. de 2012
I did not preallocate, up to you.
Keep things not dependent on the iteration outside of the loop. Also, this can be achieved without a loop.
u = 7 ;
snrdb = 5;
gama = db2mag(snrdb);
pf = 0.001:0.01:1;
p = 0:(u-2);
b = ((1 + gama)/gama).^(u-1);
for ii = 1:numel(pf)
lamda = 2*gammaincinv((1-pf(ii)),u);
a = exp(-lamda/2);
c = exp(-lamda/(2+2*gama));
x = sum((1./(factorial(p))).*((lamda/2).^p));
y = sum((1./(factorial(p))).*(((lamda*gama)/2*gama)).^p);
s(ii) = (a*x)+b.*(c-(a*y));
end
plot (pf,s);
grid on
  1 comentario
Farooq
Farooq el 9 de Abr. de 2012
i get it now thanks so much,i appreciate it @Komarov

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre Graphics en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by