- integral needs the option 'ArrayValued',true to integrate vector valued functions.
- the term 1./r in your fun1 evaluates to [Inf ...]
- you redefine l (terrible choice of a variable name btw) as your loop variable, so by the time the loop is done (once you fixed it), l will have the value 2, and not be a 3-dim array.
Evaluate a function in a grid
7 views (last 30 days)
Show older comments
I want to plot an isosurface of a function*_ v_*.
Problem is that v doesn't accept matrix arguments (not vectorizable function as it contains Laguerre associated polynomials)
So if I create a meshgrid for the values of x,y,l
[r,th,l]=meshgrid(0:0.5:5,0:pi/2:2*pi,0:2);
x=r.*cos(th);
y=r.*sin(th);
Then I suppose to evaluate v using loops (counters) as I can not bypass x , y & l as arguments
But I'm doing something wrong, and as a consequence I'm not evaluating v in the points of the grid:
for l=0:2
k=k+1;
for r=0:0.5:5
i=i+1;
for th=0:pi/2:2*pi
j=j+1;
fun1=@(R)4*real(exp(-r.^2-R^2+2*1i*R*l./r).*(r+1i*R).^(2*l).*...
(mfun('L',n/2-l/2,l,r.^2+R^2)).^2);
v(i,j,k)=integral(fun1,-inf,inf);
end
end
end
does someone knows how to do the loops so I can obtain a v that matches in size with x, y, l so I can use:
isosurface(x,y,l,v) ??
or does someone knows how to obtain the mentioned isosurface v through an alternative way?
I actually need all the help I can get to do this.
Thanks, Pablo
0 Comments
Answers (1)
Jonathan Epperl
on 24 Apr 2013
Does that code run for you? I'm sure it doesn't, you should have mentioned that, along with the error messages...
Anyway, there are several problems:
Fix that, see if it works, if it doesn't come back here, this time with error messages, please.
See Also
Categories
Find more on Polygons in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!