![]() |
请问各位大师,我这个程序的问题在哪儿
syms t1 t2;
N=100; L=0.5; dx=L/(N-1); i=sqrt(-1); u=1.257*10^(-6); e=8.854*10^(-12); o=2*pi/sqrt(u*e); k=o*sqrt(u*e); JJ=zeros(1,N-1); for n=1:N-1 if n==1; J1(n)=0*t1; JJ1(n)=subs(J1(n)); J2(n)=(((n*dx-t1)./dx).*exp(-i*k*sqrt(t1-t2).^2))./(4*pi*sqrt(t1-t2).^2); JJ2(n)=subs(J2(n)); else J1(n)=(((t1-(n-2)*dx)./dx).*exp(-i*k*sqrt(t1-t2).^2))./(4*pi*sqrt(t1-t2).^2); JJ1(n)=subs(J1(n)); J2(n)=(((n*dx-t1)./dx).*exp(-i*k*sqrt(t1-t2).^2))./(4*pi*sqrt(t1-t2).^2); JJ2(n)=subs(J2(n)); end end 下面是程序报错: ??? 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. Error in ==> QUADmn at 21 JJ1(n)=subs(J1(n)); 我是新手,请各位大师能够在百忙之总给予指点,本人感激不尽!!! |
回复: 请问各位大师,我这个程序的问题在哪儿
使用SUBS这个函数把符号变量转换为数值变量时,你把所有的符号变量运算完毕后,再对符号变量赋值,再使用SUBS进行计算,你的代码中t1都没有赋值,你无法使用SUBS ,建议你把符运算进行完在SUBS
|
所有时间均为北京时间。现在的时间是 11:05。 |
Powered by vBulletin
版权所有 ©2000 - 2025,Jelsoft Enterprises Ltd.