How do I solve the following error: error occurred converting from sym to double?

Error using Helper_Selection (line 3) The following error occurred converting from sym to double: Error using mupadmex Error in MuPAD command: DOUBLE cannot convert the input expression into a double array. If the input expression contains a symbolic variable, use the VPA function instead.
I get the above error when I run the below code. Actually, I am trying to calculate the below integral and it seems that the error occurs at the integral line. My code seams to run for a while, after which it throws above error. Dont know what's wrong, searched internet and yet cant help.
function F = decision_function(X1,X2,dx,Y1,Y2,T1,dt,mx1,mx2,my1,my2,sx1,sx2,sy1,sy2)
syms x1
syms y1
syms x2
syms y2
syms t1
syms t2
D_F1=vpa(int(int(vpa( int(int(int(int((1/(86400*sx1*sqrt(2*pi)))*exp(-(x1-mx1)^2/(2*sx1^2))*(1/(86400*sx2*sqrt(2*pi)))*exp(-(x2-mx2)^2/(2*sx2^2))*(1/(86400*sy1*sqrt(2*pi)))*exp(-(y1-my1)^2/(2*sy1^2))*(1/(86400*sy2*sqrt(2*pi)))*exp(-(y2-my2)^2/(2*sy2^2)) , y1,y2-abs(sqrt((x2-x1)^2+dx^2)),y2+abs(sqrt((x2-x1)^2+dx^2))),x1,x2-dx,x2+dx), x2, X1, X2), y2, Y1, Y2),5) ,t1,t2-dt,t2+dt ) ,t2,0,T1),5);
F=D_F1;
end
if true
% code
end
Thanks.

2 Comments

Break it up into steps so you can tell exactly where the error is. Trying to do too much at once does not save measurable processor time, and wastes a lot of programmer time.
Your inner vpa() appears to be an expression that evaluates to a specific value, not to an expression, so it appears to be a constant with respect to the outer two int(). Your outer value can then be calculated without explicit double int(): it will come out as 2 * dt * T1 times the inner amount. Doing that would reduce the work that has to be done.
I evaluated with some arbitrary constants and was able to get a value for the numeric integration (using a different symbolic package), but it is possible that some other combination of values might not work. What are some typical values for the parameters? What are the values at the time the vpa fails?

Sign in to comment.

Answers (0)

Products

Asked:

on 6 Jul 2015

Commented:

on 6 Jul 2015

Community Treasure Hunt

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

Start Hunting!