error using quad2d
Mostrar comentarios más antiguos
My code is as follows
if true
Rf=5.4E-3;
Rm=7.1E-3;
g=1;
nf=3;
nm=2;
for a=1:1:nf
rk(1,a)=sqrt(((pi*(Rf^2)*a)/nf)/pi);
end
c=1;
for b=nf+1:1:nm+nf
rk(1,b)=sqrt((c*pi*(Rm^2-Rf^2)/nm+pi*(Rf^2))/pi);
c=c+1;
end
sigma=0.1592;
FS11_l= @(theta,y)(cos(theta).^2).*exp(-(sigma.*2.*((rk(1,1).^2-y.^2).^(1/2)))/cos(theta));
FS11_r= @(theta,y) cos(theta).^2;
S_11l = quad2d (FS11_l, 0,pi/2,0,rk(1,1)); % the first term of S_11
S_11r= quad2d (FS11_r, 0,pi/2,0,rk(1,1)); % the second term of S_11
end
when running it this is shown: Warning: Matrix is singular to working precision. > In @(theta,y)(cos(theta).^2).*exp(-(sigma.*2.*sqrt((rk(1,1).^2-y.^2)))/cos(theta)) In quad2d>tensor at 343 In quad2d at 167 In Hometask2 at 21 Error using .* Matrix dimensions must agree.
Error in @(theta,y)(cos(theta).^2).*exp(-(sigma.*2.*sqrt((rk(1,1).^2-y.^2)))/cos(theta))
Error in quad2d/tensor (line 349) Z1 = FUN(X(VTSTIDX),Y(VTSTIDX)); NFE = NFE + 1;
Error in quad2d (line 167) [Qsub,esub] = tensor(thetaL,thetaR,phiB,phiT);
Error in Hometask2 (line 21) S_11l = quad2d (FS11_l, 0,pi/2,0,rk(1,1)); % the first term of S_11
Where in the equation is the dimension of the matrix messed up, how to solve this problem?
Respuestas (1)
Star Strider
el 29 de Abr. de 2016
You forgot to vectorise the last division here:
FS11_l= @(theta,y)(cos(theta).^2).*exp(-(sigma.*2.*((rk(1,1).^2-y.^2).^(1/2)))./cos(theta));
ADDED ‘.’ —> ^
Categorías
Más información sobre Surface and Mesh Plots en Centro de ayuda y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!