| Labfans是一个针对大学生、工程师和科研工作者的技术社区。 | 论坛首页 | 联系我们(Contact Us) | 
![]()  | 
	
| 		
			
			 | 
		#1 | 
| 
			
			 初级会员 
			
			
			
			注册日期: 2009-04-19 
				
				
				
					帖子: 1
				 
				
				
				声望力: 0 ![]()  | 
	
	
	
		
		
			
			 
			
			function [c,ceq]=mycon(x) 
		
		
		
		
		
		
		
	c=[sqrt((x(1)-30)^2+(x(2)-8)^2)-35; sqrt((x(1)-6)^2+(x(2)-11)^2)-35; sqrt((x(1)-12)^2+(x(2)-65)^2)-35; sqrt((x(1)-56)^2+(x(2)-28)^2)-35; sqrt((x(1)-45)^2+(x(2)-39)^2)-35]; ceq=[]; function f=myfun(x) f=200*sqrt((x(1)-30)^2+(x(2)-8)^2) +300*sqrt((x(1)-6)^2+(x(2)-11)^2) +250*sqrt((x(1)-12)^2+(x(2)-65)^2) +100*sqrt((x(1)-56)^2+(x(2)-28)^2) +150*sqrt((x(1)-45)^2+(x(2)-39)^2); clear x0=[31,36.5]; lb=[56,65]; ub=[6,8]; [x,fval]=fmincon(@fun,x0,[],[],[],[],lb,ub,@mycon) 运行结果为: x = 31.0000 36.5000 fval = [] 程序错哪了,哪位知道,谢谢了  | 
| 
		 | 
	
	
	
		
		
		
		
			 
		
		
		
		
		
		
		
			
		
		
		
	 |