I have a problem in writing the code for quad2d
Afficher commentaires plus anciens
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
Réponses (2)
Ferra
le 20 Sep 2013
0 votes
Walter Roberson
le 20 Sep 2013
0 votes
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 commentaire
Ferra
le 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
Catégories
En savoir plus sur Performance and Memory dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!