Error using mupadmex of syms
Show older comments
in th file here that is attached, this is the program that i am trying to run:
syms t
syms j
K(t)=exp(-t);
F=1;
integrand(t,j) = K(t-j)*F;
U(t)=1 - int(integrand(t,j),j,0,t);
l=1;
h=l/10;
n=round(l/h);
Utest=zeros(1,n+3);
Uapp=zeros(1,n+3);
Kvector= zeros(1,n+3);
Fvector= zeros(1,n+3);
Integvector= zeros(1,n+3);
for i=1:n+1
Integvector(i)=int(integrand(t,j),j,(i-1)*h,i*h);
end;
then i get the following error:
"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."
why is that? how can i correct it so it will work right?
Answers (1)
Ced
on 23 Oct 2014
In your second to last line
Integvector(i)=int(integrand(t,j),j,(i-1)*h,i*h);
the left side is a double vector because you initialized Integvector as such, whereas the right side is a symbolic expression still dependent on t.
So, either you initialize Integvector as a symbolic variable instead of a double vector, or you make the right side into a double by assigning a value to "t". This could be done using "subs".
Categories
Find more on Conversion in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!