| 5 | 1/1 | 返回列表 |
| 查看: 1797 | 回復(fù): 7 | ||
| 當(dāng)前只顯示滿足指定條件的回帖,點(diǎn)擊這里查看本話題的所有回帖 | ||
lynettecc新蟲(chóng) (初入文壇)
|
[求助]
matlab程序出錯(cuò)調(diào)試 已有2人參與
|
|
|
我的程序出現(xiàn)問(wèn)題,但是不知道原因請(qǐng)求各位高手幫忙,不勝感激! 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ò),請(qǐng)問(wèn)哪位高手知道哪里出錯(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); |
至尊木蟲(chóng) (著名寫(xiě)手)
驃騎將軍
|
??? 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ù)體呢? |

新蟲(chóng) (初入文壇)
|
本帖內(nèi)容被屏蔽 |
| 最具人氣熱帖推薦 [查看全部] | 作者 | 回/看 | 最后發(fā)表 | |
|---|---|---|---|---|
|
[考研] 286分調(diào)劑 +10 | Faune 2026-03-30 | 11/550 |
|
|---|---|---|---|---|
|
[考研] 083000環(huán)境科學(xué)與工程調(diào)劑,總分281 +3 | 橙子(勝意) 2026-03-30 | 3/150 |
|
|
[考研]
|
鐘llll 2026-03-26 | 5/250 |
|
|
[考研] 310求調(diào)劑 +10 | 爭(zhēng)取九點(diǎn)睡 2026-03-30 | 10/500 |
|
|
[考研] 085404求調(diào)劑,總分309,本科經(jīng)歷較為豐富 +6 | 來(lái)財(cái)aa 2026-03-25 | 6/300 |
|
|
[考研] 085600,材料與化工321分求調(diào)劑 +10 | 大饞小子 2026-03-28 | 10/500 |
|
|
[考研] 一志愿北京工業(yè)大學(xué),324分求調(diào)劑 +6 | 零八# 2026-03-28 | 6/300 |
|
|
[考研] 289求調(diào)劑 +5 | BrightLL 2026-03-29 | 5/250 |
|
|
[考研] 356求調(diào)劑 +4 | gysy?s?a 2026-03-28 | 4/200 |
|
|
[考研] 315求調(diào)劑 +4 | akie... 2026-03-28 | 5/250 |
|
|
[考研] 一志愿南京航空航天大學(xué)材料學(xué)碩求調(diào)劑 +3 | @taotao 2026-03-28 | 3/150 |
|
|
[考研] 張芳銘-中國(guó)農(nóng)業(yè)大學(xué)-環(huán)境工程專碩-298 +4 | 手機(jī)用戶 2026-03-26 | 4/200 |
|
|
[考研] 295求調(diào)劑 +5 | 1428151015 2026-03-27 | 6/300 |
|
|
[考研] 314求調(diào)劑 +3 | 溪云珂 2026-03-26 | 3/150 |
|
|
[考研] 一志愿吉大071010,316分求調(diào)劑 +3 | xgbiknn 2026-03-27 | 3/150 |
|
|
[考研] 324求調(diào)劑 +5 | hanamiko 2026-03-26 | 5/250 |
|
|
[考研] 321求調(diào)劑 +6 | Ymlll 2026-03-24 | 6/300 |
|
|
[考研] 調(diào)劑 +4 | 柚柚yoyo 2026-03-26 | 4/200 |
|
|
[考研] 309求調(diào)劑 +4 | gajsj 2026-03-25 | 5/250 |
|
|
[考研] 285求調(diào)劑 +3 | AZMK 2026-03-24 | 3/150 |
|