How to do iterative integral with anonymous functions?
Ältere Kommentare anzeigen
My code looks as follows:
function iter = Iteration(omega)
global zeta ratio
fun = @(x,y) exp(-x.^2/4).*x.^2.*(3*besseli(0,x.*y*1/2) -4*besseli(1,x.*y*1/2)+besseli(2,x.*y*1/2))./(myGamma(omega));
fun2 = @(y) ratio^2/4*exp(-y.^2/4).*integral(@(x) fun(x,y),0,30);
fun3 = @(x,y) exp(-x.^2/4).*x.^2.*(3*besseli(0,x.*y*1/2) -4*besseli(1,x.*y*1/2)+besseli(2,x.*y*1/2))./(myGamma(omega) - x.*fun2(x));
fun8 = @(y) ratio^2/4*exp(-y.^2/4).*integral(@(x) fun3(x,y),0,30);
iter = fun8(zeta);
end
function gamma = myGamma(omega)
gamma = 1-omega^2;
end
The main problem is in the line:
fun3 = @(x,y) exp(-x.^2/4).*x.^2.*(3*besseli(0,x.*y*1/2) -4*besseli(1,x.*y*1/2)+besseli(2,x.*y*1/2))./(myGamma(omega) - x.*fun2(x));
because fun2(x) has been defined as an anonymous function with a y-parameter, so fun2(x) won't work. Is it possible to get the anonymous function to be passed a different parameter so I can iterate it?
1 Kommentar
Wouter
am 28 Mär. 2013
You can't put an anonymous function in an anonymous function I guess; try this:
fun2 = @(x,y) ratio^2/4*exp(-y.^2/4).*integral(fun(x,y)),0,30);
Antworten (0)
Kategorien
Mehr zu Structural Mechanics finden Sie in Hilfe-Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!