Error 'DOUBLE cannot convert the input expression into a double array'
2 ビュー (過去 30 日間)
古いコメントを表示
I have symbolically integrated as following
function[flux]= superquad2(a1,a2,a3, epsilon1,epsilon2,epsilon3)
syms eta w
wmin=-pi/2;
wmax=pi/2;
etamin=-pi;
etamax=pi;
elp_x = a1.*abs(cos(eta)).^epsilon1.*abs(cos(w)).^epsilon1.*sign(cos(eta)).*sign(cos(w));
elp_y = a2.*abs(cos(eta)).^epsilon2.*abs(sin(w)).^epsilon2.*sign(cos(eta)).*sign(sin(w));
elp_z = a3.*abs(sin(eta)).^epsilon3.*sign(sin(eta));
ellipsoid=[elp_x,elp_y,elp_z];
ndseta=diff(ellipsoid,eta);
ndsw=diff(ellipsoid,w);
nds=cross(ndseta,ndsw);
F=[(a1.*abs(cos(eta)).*abs(cos(w))),(a2.*abs(cos(eta)).*abs(sin(w))),(a3.*abs(sin(eta)))];
F_par=subs(F,[(a1.*sign(cos(eta)).*abs(cos(eta)).*sign(cos(w)).*abs(cos(w))),(a2.*sign(cos(eta)).*abs(cos(eta)).*sign(sin(w)).*abs(sin(w))),(a3.*sign(sin(eta)).*abs(sin(eta)))],ellipsoid);
realdot=@(u,v)u*transpose(v);
fflux=realdot(F_par,nds);
fluxxx=symint2(fflux,w,wmin,wmax,eta,etamin,etamax);
fluxxxx=eval(fluxxx);
flux=double(fluxxxx);
end
To test the stability of the code, when I call this function with integer exponents it converges to a solution, but when I try with this
superquad2(25,25,25,.33,.66,.33)
the function returns the following error
Error using symengine
DOUBLE cannot convert the input expression into a double array.
Error in sym/double (line 643)
Xstr = mupadmex('symobj::double', S.s, 0);
Error in superquad2 (line 21)
flux=double(fluxxxx);
I could not understand it. I am starting to debug it but it doesn't help much.
Please help me to resolve the issue.
7 件のコメント
Walter Roberson
2019 年 1 月 11 日
you should never eval something that is symbolic . The expression language used by the symbolic toolbox is not exactly the same as MATLAB .
回答 (2 件)
Walter Roberson
2019 年 1 月 11 日
you should be using vpaintegral instead of int for that code.
double() of an int() forces int to try numeric integration, but with a different strategy than vpaintegral .
numeric integration through double() of int() or through vpaintegral() can fail such as if the function diverges or does not converge like int of sin to infinity . When you use double the only way to deal with that is try/catch. When you use vpaintegral it will reply back with aa vpaintegral when it is not able to calculate and you can look at the length of children() to determine whether you got back aa numeric result .
2 件のコメント
Walter Roberson
2019 年 1 月 11 日
vpaintegral is not a two dimensional .you need nested vpaintegral just like you use nested int()
Hirak
2019 年 1 月 14 日
編集済み: Hirak
2019 年 1 月 14 日
5 件のコメント
Walter Roberson
2019 年 1 月 16 日
You have a few choices:
- carefully control your integrations to not cross any of the singularities. As the singularties are not removable, then how close you get to the singularities will be important, as you will be adding and subtracting values approaching infinity.
- Check your equations again multiple times, paying particular attention to denominators and how they arise and why they can be zero. Perhaps you will find a reason why those situations do not really arise and can be avoided for your situation
- Check your equations again multiple times, paying particular attention to denominators and how they arise and why they can be zero. Perhaps you will find a reason why your situation is not solvable. For example, you have abs() and diff(abs) is not defined which tells you that your problem is not well posed.
- You could give up.
参考
カテゴリ
Help Center および File Exchange で Assumptions についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!