DOUBLE cannot convert the input expression into a double array
10 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
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
2 comentarios
Walter Roberson
el 4 de Mzo. de 2013
After the solve(), please show use "y", and show class() and size() of all the names that are mentioned in y (that is, the ones that would be affected by the subs())
Respuesta aceptada
Walter Roberson
el 4 de Mzo. de 2013
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).
10 comentarios
Más respuestas (1)
Azzi Abdelmalek
el 3 de Mzo. de 2013
Editada: Azzi Abdelmalek
el 3 de Mzo. de 2013
Try
subs(y)
Example
y=solve('x+1');
whos y
r=subs(y)
whos r
Also
if isempty(y)==1 is the same as if isempty(y)
15 comentarios
Ver también
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!