integration Question Matlab error
Mostrar comentarios más antiguos
Hi i am having trouble integrating a function for a program that i am writing, i have been trying to fix it for a while and i have had no luck im hoping someone here with a little bit more experience can help me. Basically i have a network and i am trying to figure out a function called a local function at each node in the network, thats a big vague but i dont want to bore you with too much detail, here the code i wrote.
for i=1:num
b = (distancePU(1,i)/distancePU(1,i))^(-pathloss);
q = randn(2) * sqrt(1) + 0;
PDFpu = ((1/abs(b))*(2*(q/b))/((((q/b)^2)+1)^2));
a = (RSSattacker(i)/RSSattacker(i))/pi;
PDFattacker = (1/(abs(a)))*((2*(q/a))/((((q/a)^2)+1)^2));
KL = @(q) PDFpu * log(PDFpu/PDFattacker);
KLint = integral(KL,0,1); % KL integral
end
I am basically computing all the terms one by one and then integrating them in the KLint function and i keep getting the same error "Output of the function must be the same size as the input. If FUN is an array-valued integrand, set the 'ArrayValued' option to true." i cant really figure out what the problem is, any advice would be appreciated.
Respuesta aceptada
Más respuestas (0)
Categorías
Más información sobre Numerical Integration and Differentiation en Centro de ayuda y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!