| Labfans是一个针对大学生、工程师和科研工作者的技术社区。 | 论坛首页 | 联系我们(Contact Us) | 
![]()  | 
	
| 		
			
			 | 
		#1 | 
| 
			
			 初级会员 
			
			
			
			注册日期: 2008-09-05 
				
				年龄: 49 
				
					帖子: 2
				 
				
				
				声望力: 0 ![]()  | 
	
	
	
		
		
			
			 
			
			请教一下各位英雄:  
		
		
		
		
		
		
		
	我写了一个关于优化问题的东西,M文件opt25_3o.m为: function f=myfun(x) f=0.192457*10^(-4)*(x(2)+2)*x(1)^2*x(3) M文件opt25_3c.m为: function [c,ceq]=mycon(x) c(1)=350-163*x(1)^(-2.86)*x(3)^(0.86); c(2)=10-0.4*0.01*x(1)^(-4)*x(2)*x(3)^3; c(3)=(x(2)+1.5)*x(1)+0.44*0.01*x(1)^(-4)*x(2)*x(3)^3-3.7*x(3); c(4)=375-0.356*10^6*x(1)*x(2)^(-1)*x(3)^(-2); c(5)=4-x(3)/x(1); 然后在命令窗口写的为: A=[-1 0 0;1 0 0;0 -1 0;0 1 0;0 0 -1;0 0 1]; >> b=[-1;4;-4.5;50;;-10;30]; >> x0=[2.0; 5.0; 25.0]; >> lb=zeros(3,1); >> [x,fval,exitflag,output,lambda]=fmincon(@opt25_3o,x0,A,b,[],[],lb,[],@opt25_3c) 可是结果有问题,显示为: Warning: Large-scale (trust region) method does not currently solve this type of problem, switching to medium-scale (line search). > In fmincon at 274 f = 0.0135 ??? Error using ==> fmincon FMINCON cannot continue because user supplied nonlinear constraint function failed with the following error: Output argument "ceq" (and maybe others) not assigned during call to "D:\matlab\work\opt25_3c.m (opt25_3c)". 这是怎么回事啊?应该怎么解决呢? 谢谢  | 
| 
		 | 
	
	
	
		
		
		
		
			 
		
		
		
		
		
		
		
			
		
		
		
	 | 
| 		
			
			 | 
		#2 | 
| 
			
			 初级会员 
			
			
			
			注册日期: 2008-01-17 
				
				年龄: 42 
				
					帖子: 6
				 
				
				
				声望力: 0 ![]()  | 
	
	
	
		
		
			
			 
			
			你先在matlab的help里面查一下此函数的用法,那上面有使用说明 
		
		
		
		
		
		
			好像你的非线性函数调出变量时有问题 
				__________________ 
		
		
		
		
	大家好!新手上路请多多关照。:confused:  
			 | 
| 
		 | 
	
	
	
		
		
		
		
			 
		
		
		
		
		
		
		
			
		
		
		
	 | 
| 		
			
			 | 
		#3 | 
| 
			
			 游客 
			
			
			
			
					帖子: n/a
				 
				
				
				
				
				 | 
	
	
	
		
		
			
			 
			
			谢谢您的帮助
		 
		
		
		
		
		
		
		
	 | 
	
		
		
		
		
			 
		
		
		
		
		
		
		
			
		
		
		
	 | 
![]()  | 
	
	
		
  | 
	
		 | 
			 
			相似的主题
		 | 
	||||
| 主题 | 主题作者 | 版面 | 回复 | 最后发表 | 
| [分享]用MATLAB实现遗传算法程序 | guofeng0108 | MATLAB论坛 | 31 | 2010-11-15 23:06 | 
| [求助]图像像素间的相关性? | hippo613 | MATLAB论坛 | 1 | 2009-01-09 08:36 | 
| 菜鸟问题,为什么我用MATLAB7.01不支持符号运算 | cyf0596 | MATLAB论坛 | 2 | 2008-11-25 08:41 | 
| [分享]计算方法matlab程序 | guofeng0108 | MATLAB论坛 | 2 | 2008-11-18 03:43 | 
| 关于采样 | tomasso | MATLAB论坛 | 0 | 2008-11-13 10:04 |