Optimizaation problem in matlab
조회 수: 4 (최근 30일)
이전 댓글 표시
Hi,
I have a function in matlab which is dependent on four variable ( x1,x2,x3 and x4). I want to optimize the function output in matlab. I have access to optimization toolbox but i dont know anything about it.
For my fucntion i cant write function model because output of the function is a complex calculation invoving 100 lines of code.Basically i want to optimize a function output, depending on the four variable within given limits.
Anybody knows how i can proceed ?
댓글 수: 0
채택된 답변
Titus Edelhofer
2012년 1월 4일
Hi Sukuchha,
it doesn't matter how complex your function is or how many lines it has. What you need to do is (conceptually) simple: write a function (with as many lines of code as you like) that has the following structure:
function y = myfun(x)
% x is the vector of unknowns, if you like you could write:
x1 = x(1);
x2 = x(2);
x3 = x(3);
x4 = x(4);
% now come the many lines to compute what ever you want to have
% optimized, i.e., some lengthy computations leading to some y
% where the final y you are looking for fulfills
% |y(xFinal)| = minimum of all x
y = ...;
Then think of bounds for x and call
x0 = [1;1;1;1]; % or some better starting point
lb = [1 2 3 4]; % the lower bounds for your parameters
ub = [5 6 7 8]; % the upper bounds for your parameters
xOpt = fmincon(@myfun, x0, [], [], [], [], lb, ub);
Titus
추가 답변 (0개)
참고 항목
카테고리
Help Center 및 File Exchange에서 Surrogate Optimization에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!