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!