Reputation: 29
a=2;
b=9; %the variance
syms x
i0=besseli(0,a*x/b);
fx=(x/b)*exp(-(x^2+a^2)/(2*b))*i0;
fun=matlabFunction(x*fx);
mean=quad(fun,0,282);
How can I plot fx
and the integral of fx
?
Upvotes: 2
Views: 247
Reputation: 32873
To plot, you can do
xx = 0:.1:10;
fxx = matlabFunction(fx);
plot(xx, fxx(xx))
or
fxx = matlabFunction(fx);
fplot(fxx, [0 10])
And for the integral, one solution is:
fxx = matlabFunction(fx);
ifxx = @(x) integral(fxx,0,x);
fplot(ifxx, [0 10])
This is to get you going. I hope there will better answers.
Upvotes: 2
Reputation: 13758
There's a suite of "ez" ("easy") plot functions to handle this. ezplot
, ezsurf
, ezmesh
, and so on...
See http://www.mathworks.com/help/symbolic/plot-functions-and-data.html for more information on the plotting functions supplied with the Symbolic Math Toolbox.
Upvotes: 0
Reputation: 1058
Try using function "subs". That sound to be like this:
for i = Xstart:Xend
y(i) = subs(f,x,i);
end
plot(Xstart:Xend,y)
I hope I could helped.
Upvotes: 0