| Labfans是一个针对大学生、工程师和科研工作者的技术社区。 | 论坛首页 | 联系我们(Contact Us) | 
![]()  | 
	
| 		
			
			 | 
		#1 | 
| 
			
			 初级会员 
			
			
			
			注册日期: 2011-08-06 
				
				
				
					帖子: 1
				 
				
				
				声望力: 0 ![]()  | 
	
	
	
		
		
			
			 
			
			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)); 我是新手,请各位大师能够在百忙之总给予指点,本人感激不尽!!!  | 
| 
		 | 
	
	
	
		
		
		
		
			 
		
		
		
		
		
		
		
			
		
		
		
	 | 
| 		
			
			 | 
		#2 | 
| 
			
			 初级会员 
			
			
			
			注册日期: 2009-01-15 
				
				年龄: 36 
				
					帖子: 15
				 
				
				
				声望力: 17 ![]()  | 
	
	
	
		
		
			
			 
			
			使用SUBS这个函数把符号变量转换为数值变量时,你把所有的符号变量运算完毕后,再对符号变量赋值,再使用SUBS进行计算,你的代码中t1都没有赋值,你无法使用SUBS ,建议你把符运算进行完在SUBS
		 
		
		
		
		
		
		
		
	 | 
| 
		 | 
	
	
	
		
		
		
		
			 
		
		
		
		
		
		
		
			
		
		
		
	 |