I have a problem in writing the code for quad2d

1 view (last 30 days)
Hi
Could anyone tell me what's the problem with this code:
fun = @(x,y) (1./(2.* pi.* rint)) .* exp( - (x.^2 + y.^2)/(2.*rint)).*fint;
Q = @(theta,r) fun(r.*cos(theta),r.*sin(theta)).*r;
q = quad2d(Q,0,pi/2,0,rint);
rint is function based on a parameter that I want to estimate later.
Thanks
  2 Comments
Ferra
Ferra on 19 Sep 2013
It says:
Error using quad2d (line 124) D must be a finite, scalar, floating point constant or a function handle.
Error in myfunstar (line 51) q = quad2d(Q,0,pi/2,0,rint);

Sign in to comment.

Answers (2)

Ferra
Ferra on 20 Sep 2013
Any idea? Please someone tell me what's the problem with this code!
I really appreciate it!

Walter Roberson
Walter Roberson on 20 Sep 2013
Your "rint" is not a finite scalar floating point constant or a function handle, and so is not value as the last parameter in quad2d()
Please show the content of rint. You mention it being a function: is it a function handle or is it the name of a function defined with "function ... = rint ..." ?
  1 Comment
Ferra
Ferra on 20 Sep 2013
Thank you for your response.The following is the code that I wrote and I want to minimize the function and estimate x (in another file I wrote the code for fminsearch). So you mean I should define rint as a function and bring it as a function handle as the last parameter in quad2d? But how?!
function f = myfunstar2(x,T,H,R)
p=1000; D=100;
lams=sqrt(x(1)*exp(-x(3)/(T)));
lamw=sqrt(x(2)*exp(-x(4)/(T)));
As = p^2 - (pi* (D^2) /4); d = 1000;
rint = lams + (D/2);
b = sqrt ((d.^2)+2.*(rint.^2)+rint.*(2.*D)+2.*(D.^2));
fint = (((2.*(asin (b ./2.*rint)./180).*(pi.*rint .^2) - (b .* d)./2)).^4) ./ (As .^ 4);
fun = @(x,y) (1./(2 .* pi .* rint)) .* exp( - (x.^2 + y.^2)/(2.*rint)).*fint;
Q = @(theta,r) fun(r.*cos(theta),r.*sin(theta)).*r;
q = quad2d(Q,0,pi/2,0,rint);
ks = 4 * ((pi*(rint^2))/pi* ((D^2)/4))* q *(((lams^2))/((D^2)/4));
kw=((pi*D*H)/(pi*(D^2)/4)*(lamw/H));
rate= ks+kw;
f = sum((rate - R)^2);
end

Sign in to comment.

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!