I have a function of two variable to double integrate but i can not use symbolic integration as i want to compile this to .exe file.
clc;
sig=0.5; L=4; k=1.0472; k_sig=k*sig; kls=k*ls; er=3.5; theta=(0:10:70)'; g=length(theta); Q=zeros(g,1);
for i=1:g;
cs=cosd(theta(i)); s=sind(theta(i)); s2=s.*s; cs2=cs.*cs; ks=k.*sig; kL=k.*L; ks2=ks.*ks; kL2=kL.*kL; %(*Integration variables*)
r2=@(r)(r.*r); sf=@(phi)sin(phi); csf=@(phi)cos(phi); rx=@(r,phi)(r.*csf(phi)); ry=@(r,phi)(r.*sf(phi));
Wmh=0; Wnh=0.0;
for n=1:4;
for m=1:4; wn=@(r,phi)(n.*kL2./(n.*n + kL2.*((rx(r,phi) - s).^2... + ry(r,phi).^2))^1.5); wm=@(r,phi)(m.*kL2./(m.*m + kL2.*((rx(r,phi) + s).^2... + ry(r,phi).^2))^1.5); vhmn=((ks2.*cs2).^(n+m))./(factorial(m).*factorial(n)); Wm=@(r,phi)(vhmn.*wn(r,phi).*wm(r,phi)); Wmh=@(r,phi)(Wmh(r,phi)+Wm(r,phi)); end
end
Wnh=@(r,phi)(Wnh(r,phi)+Wmh(r,phi)); VH=@(r,phi)(Wnh(r,phi).*r);
%% Double Integration
Q(i)=quad2d(VH,0,1,0,pi/4);
end
HV=10*log10(Q); table=[theta HV]
This is giving Error:
Error:
Subscript indices must either be real positive integers or logicals. Error in @(r,phi)(Wnh(r,phi)+Wmh(r,phi)) Error in @(r,phi)(Wnh(r,phi).*r) Error in quad2d/tensor (line 344) Z = FUN(X,Y); NFE = NFE + 1; Error in quad2d (line 168)[Qsub,esub] = tensor(thetaL,thetaR,phiB,phiT); Error in Untitled1 (line 32) Q(i)=quad2d(VH,0,1,0,pi/4);
>>
Best Answer