| 8 | 1/1 | 返回列表 |
| 查看: 1789 | 回復(fù): 7 | ||
lynettecc新蟲 (初入文壇)
|
[求助]
matlab程序出錯(cuò)調(diào)試 已有2人參與
|
|
我的程序出現(xiàn)問題,但是不知道原因請求各位高手幫忙,不勝感激! function f = statefunction(xx) global mu lam10 Tmp TmE global n x=xx(1:n); x=reshape(x,n,1); u=xx(end-1:end); %x1=x(1),x2=x(2),x3=x(3),x4=x(4),x5=x(5),x6=x(6),x7=x(7),x8=x(8),x9=x(9),x10=x(10),x11=x(11),x12=x(12) % lamb7'=x(13),lamb8'=x(14),lamb9'=x(15),lamb11'=x(16),lamb12'=x(17) %控制變量u1,u2 u1=u(1); u2=u(2); %控制變量u3,u4 uu1=controlE1(x); u3=uu1(1); u4=uu1(2); function y=controlE1(x) %x1=x(1),x2=x(2),x3=x(3),x4=x(4),x5=x(5),x6=x(6),x7=x(7),x8=x(8),x9=x(9),x10=x(10),x11=x(11),x12=x(12) % lamb7'=x(13),lamb8'=x(14),lamb9'=x(15),lamb11'=x(16),lamb12'=x(17) %x1=x(1),x2=x(2),x3=x(3),x4=x(4),x5=x(5),x6=x(6),x7=x(7),x8=x(8),x9=x(9),x10=x(10),x11=x(11),x12=x(12) %lamb1=x(13),lamb2=x(14),lamb3=x(15),lamb4=x(16),lamb5=x(17),lamb6=x(18),... %lamb7=x(19),lamb8=x(20),lamb9=x(21),lamb10=x(22),lamb11=x(23),lamb12=x(24); options = optimset('TolFun',1e-6,'TolCon',1e-8); options = optimset(options,'Algorithm','sqp'); uuE = fmincon(@(xx) myfun1(xx,x),[0;0],[],[],[],[],[-pi;-pi],[pi;pi],@(xx) cons1(xx,x),options); u3=uuE(1); u4=uuE(2); y=zeros(2,1); y(1)=u3; y(2)=u4; function q=myfun1(p,x) global TmE u3=p(1); u4=p(2); a=TmE*cos(u4)/x(8)*(x(15)*cos(u3)-x(8)*x(14)*sin(u3)); b=-TmE*x(14)*sin(u4)*cos(u3)+TmE/x(8)*(x(17)*cos(u4)/cos(x(9))-x(15)*sin(u3)*sin(u4)); q=a^2+b^2; function [c ceq]=cons1(p,x) global TmE u3=p(1); u4=p(2); H11=-TmE*cos(u4)/x(8)*(x(8)*x(14)*cos(u3)+x(15)*sin(u3)); H12=TmE*sin(u4)/x(8)*(x(8)*x(14)*sin(u3)-x(15)*cos(u3)); H22=-TmE*(1/x(8)*(x(15)*sin(u3)*cos(u4)+x(17)*sin(u4)/cos(x(9)))+x(14)*cos(u3)*cos(u4)); c=zeros(2,1); c(1)=H11+H22; c(2)=-(H11*H22-H12*H12); ceq=[]; 如上程序運(yùn)行時(shí)報(bào)錯(cuò),請問哪位高手知道哪里出錯(cuò)嗎? ??? Error using ==> sqpLineSearch at 20 Objective function is undefined at initial point. Fmincon cannot continue. Error in ==> fmincon at 816 [X,FVAL,EXITFLAG,OUTPUT,LAMBDA,GRAD,HESSIAN] = sqpLineSearch(funfcn,X,full(A),full(B),full(Aeq),full(Beq), ... Error in ==> controlE1 at 17 uuE = fmincon(@(xx) myfun1(xx,x),[0;0],[],[],[],[],[-pi;-pi],[pi;pi],@(xx) cons1(xx,x),options); Error in ==> statefunction at 14 uu1=controlE1(x); |
至尊木蟲 (著名寫手)
驃騎將軍
|
??? Error using ==> sqpLineSearch at 20 Objective function is undefined at initial point. Fmincon cannot continue. sqpLineSearch函數(shù)中,目標(biāo)函數(shù)在初始點(diǎn)未定義.sqpLineSearch 這個(gè)函數(shù)體呢? |

新蟲 (初入文壇)
|
本帖內(nèi)容被屏蔽 |
銅蟲 (初入文壇)


| 8 | 1/1 | 返回列表 |
| 最具人氣熱帖推薦 [查看全部] | 作者 | 回/看 | 最后發(fā)表 | |
|---|---|---|---|---|
|
[考研] 求調(diào)劑 +3 | 李李不服輸 2026-03-25 | 3/150 |
|
|---|---|---|---|---|
|
[考研] 考研化學(xué)308分求調(diào)劑 +10 | 你好明天你好 2026-03-23 | 11/550 |
|
|
[考研] 303求調(diào)劑 +3 | 藍(lán)山月 2026-03-25 | 3/150 |
|
|
[考研] 300分,材料,求調(diào)劑,英一數(shù)二 +5 | 超贊的 2026-03-24 | 5/250 |
|
|
[考研] 一志愿北化315 求調(diào)劑 +3 | akrrain 2026-03-24 | 3/150 |
|
|
[考研] 321求調(diào)劑 +4 | Ymlll 2026-03-24 | 4/200 |
|
|
[考研] 327求調(diào)劑 +5 | prayer13 2026-03-23 | 5/250 |
|
|
[考研]
|
2117205181 2026-03-21 | 8/400 |
|
|
[考研] 一志愿華中農(nóng)業(yè)071010,總分320求調(diào)劑 +5 | 困困困困坤坤 2026-03-20 | 6/300 |
|
|
[考研] 308求調(diào)劑 +3 | 墨墨漠 2026-03-21 | 3/150 |
|
|
[考研] 260求調(diào)劑 +3 | 朱芷琳 2026-03-20 | 4/200 |
|
|
[考研] 生物學(xué)調(diào)劑 +5 | Surekei 2026-03-21 | 5/250 |
|
|
[考研] 考研調(diào)劑 +4 | 來好運(yùn)來來來 2026-03-21 | 4/200 |
|
|
[考研] 求調(diào)劑 +4 | 要好好無聊 2026-03-21 | 4/200 |
|
|
[考研] 一志愿重慶大學(xué)085700資源與環(huán)境總分308求調(diào)劑 +7 | 墨墨漠 2026-03-20 | 7/350 |
|
|
[考研] 330求調(diào)劑0854 +3 | assdll 2026-03-21 | 3/150 |
|
|
[考研] 304求調(diào)劑 +7 | 司空. 2026-03-18 | 7/350 |
|
|
[考研]
|
然11 2026-03-19 | 4/200 |
|
|
[考研]
|
簡木ChuFront 2026-03-19 | 8/400 |
|
|
[考研] 材料學(xué)碩318求調(diào)劑 +5 | February_Feb 2026-03-19 | 5/250 |
|