How do I plot functions involving integration?
Ältere Kommentare anzeigen
I have a characteristic function CF(t, param1, param2, ...) available (here param's are parameters of some probability distribution and are considered fixed). I want to use the Gil-Pelaez formula to obtain the CDF instead, so I wrote the following:
function [ F ] = CDF( x, param1, param2, ... )
integrand = @(v) imag(exp(-1i.*v.*x) .* CF(t, param1, param2, ...)) ./ v;
F = 0.5 - (1./pi) .* integral(integrand, 0, 100);
end
This works for single value, e.g. CDF(0.1, param1, param2, ...) gives me desired result. Now I want to plot CDF against a range of x, so I did:
x = linspace(-1,1,100);
y = CDF(x, param1, param2, ...)
plot(x, y)
and I end up with the errors like these:
Not enough input arguments.
Error in integralCalc/iterateScalarValued (line 314)
fx = FUN(t);
Error in integralCalc/vadapt (line 132)
[q,errbnd] = iterateScalarValued(u,tinterval,pathlen);
Error in integralCalc (line 75)
[q,errbnd] = vadapt(@AtoBInvTransform,interval);
Error in integral (line 88)
Q = integralCalc(fun,a,b,opstruct);
But y = CDF(x, param1, param2, ...) does work, so the culprit seems to be the exp(-1i.*v.*x) part of the integrand, as the size of v and x does not match. But I am not sure how to fix this.
1 Kommentar
Brendan Hamm
am 23 Dez. 2015
I removed the plot tag as this question really has nothing to do with the plotting. I would suggest a question Title change as well.
Akzeptierte Antwort
Weitere Antworten (0)
Kategorien
Mehr zu Loops and Conditional Statements finden Sie in Hilfe-Center und File Exchange
Produkte
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!