MATLAB: DOUBLE cannot convert the input expression into a double array

solve double

This is the code. Could anyone run it and give me some suggestion about the error 'DOUBLE cannot convert the input expression into a double array' ? Cheers!
if true % DD =
1.2000 0.6000 1.6000 0.5000 1.3000 1.4000 100.0000
1.2000 0.6000 1.6000 0.5000 1.3000 1.6000 100.0000
1.2000 0.6000 1.6000 0.5000 1.3000 1.8000 100.0000
1.2000 0.8000 1.6000 0.7000 1.2000 1.4000 100.0000
1.2000 0.6000 1.4000 0.7000 1.2000 1.4000 100.0000
1.3000 0.6000 1.6000 0.7000 1.3000 1.4000 100.0000
1.3000 0.6000 1.6000 0.7000 1.3000 1.4000 100.0000
1.4000 0.4000 1.6000 0.6000 1.5000 1.4000 100.0000
1.4000 1.6000 0.4000 0.8000 1.1000 1.2000 100.0000
1.4000 1.8000 0.4000 0.8000 1.1000 1.2000 100.0000
1.4000 2.0000 0.4000 0.8000 1.1000 1.2000 100.0000
1.2000 2.2000 0.3000 0.8000 1.1000 1.2000 100.0000
1.5000 1.6000 0.4000 0.6000 1.1000 1.3000 100.0000
1.5000 1.3000 0.4000 0.6000 1.5000 1.3000 100.0000
1.2000 2.0000 0.7000 0.8000 1.1000 1.2000 100.0000
1.1000 2.0000 0.7000 0.8000 1.1000 1.2000 100.0000
0.5000 1.3000 1.5000 1.4000 0.6000 0.8000 100.0000
0.4000 1.5000 1.5000 1.4000 0.6000 0.8000 100.0000
1.1000 0.5000 1.5000 0.4000 1.2000 1.5000 100.0000
1.1000 0.5000 1.5000 0.4000 1.2000 1.7000 100.0000
1.1000 0.5000 1.5000 0.6000 1.1000 1.3000 100.0000
1.3000 0.3000 1.5000 0.5000 1.4000 1.3000 100.0000
1.1000 0.5000 1.6000 0.4000 1.2000 1.5000 100.0000
1.1000 0.5000 1.7000 0.4000 1.2000 1.5000 100.0000
1.1000 0.6000 1.5000 0.4000 1.2000 1.5000 100.0000
1.3000 0.5000 1.5000 0.4000 1.2000 1.5000 100.0000
1.1000 0.5000 1.6000 0.4000 1.2000 1.5000 100.0000
1.1000 0.8000 1.6000 0.7000 1.2000 1.5000 100.0000
1.1000 0.5000 1.5000 0.4000 1.4000 1.7000 100.0000
1.1000 0.6000 1.5000 0.4000 1.2000 1.7000 100.0000
1.1000 0.5000 1.5000 0.4000 1.2000 1.7000 100.0000
1.1000 0.5000 1.5000 0.4000 1.2000 1.7000 100.0000
1.1000 0.5000 1.5000 0.8000 1.2000 1.7000 100.0000
1.1000 0.5000 1.5000 0.4000 1.2000 1.7000 100.0000
1.1000 0.9000 1.5000 0.4000 1.2000 1.7000 100.0000
1.8000 0.5000 1.5000 0.4000 1.2000 1.7000 100.0000
0.9000 0.5000 1.5000 0.8000 1.2000 1.3000 100.0000
1.1000 0.6000 1.5000 0.8000 1.2000 1.7000 100.0000
0.8000 0.5000 1.8000 0.8000 1.2000 1.7000 100.0000
rn=size(DD,1);
sub=[0.25,0.25,0.25,0.08]
p1=sub(1);
p2=sub(2);
p3=sub(3);
r=sub(4);
eutotal=zeros(rn,5);
eu=zeros(1,rn);
for i=1:rn;
d1=DD(i,1:3)-1;
d2=DD(i,4:6)-1;
edw=DD(i,7);
syms x;
%f=@(x)
f=p1*(d1(1,1)-d2(1,1))*exp(-r*x*(d1(1,1)-d2(1,1)))...
+p2*(d1(1,2)-d2(1,2))*exp(-r*x*(d1(1,2)-d2(1,2)))...
+p3*(d1(1,3)-d2(1,3))*exp(-r*x*(d1(1,3)-d2(1,3)));
y=solve(f,x)
isempty(y);
if isempty(y)
PF(1,1)=10;
else
PF=double(y);
end
end
end

Best Answer

Okay, I think I understand what is going on.
Sometimes MuPAD (the symbolic engine) creates expressions along the lines of
... * z1 .... where z1 = ...
That is, it extracts a complicated sub-expression and gives it a name, and then at the end says "where" and gives a definition for the sub-expression.
Unfortunately when this happens, the MATLAB interface drops the clause defining the subexpression, leaving a z* variable that did not exist in the original expression. This is, of course, a bug. And it seems to happen more in more recent versions (including in R2012a)
If you start up a MuPAD notepad with the "mupad" command, and solve() the expression inside it, you will see MuPAD's fuller answer.
In the case of the "f" you show above, general solution is
125*ln(RootOf(7*z^14-2*z^5-7,z))
where RootOf(7*z^14-2*z^5-7,z) means all of the values of "z" such that 7*z^14-2*z^5-7 comes out as 0 (the "roots" of the expression).