[問題]請問哪裡有錯(函數用法)已回收
這是help理的範例
我複製照著做
function [c, ceq] = confun(x)
% Nonlinear inequality constraints
c = [1.5 + x(1)*x(2) - x(1) - x(2);
-x(1)*x(2) - 10];
% Nonlinear equality constraints
ceq = [];
以上存在m.file裡
x0 = [-1,1]; % Make a starting guess at the solution
options = optimset('LargeScale','off');
[x, fval] = ...
fmincon(@objfun,x0,[],[],[],[],[],[],@confun,options)
然後去跑...但出現Error using ==> fmincon
FMINCON cannot continue because user supplied objective function failed with the following error:
Error: File: C:\Program Files\MATLAB71\work\objfun.m Line: 13 Column: 1
Function definitions are not permitted at the prompt or in scripts.
我該如何修改?
--
※ 發信站: 批踢踢實業坊(ptt.cc)
◆ From: 163.23.203.217
討論串 (同標題文章)
以下文章回應了本文:
完整討論串 (本文為第 1 之 2 篇):
MATLAB 近期熱門文章
PTT數位生活區 即時熱門文章