A simple optimization problem that has been solved many years ago is the biggest field area with constant surrounding. Also imagine that a carpenter need to build a wooden window like below.

window optimization problem

He need to know with constant timber length, how should he build the vastest window. To determine this problem using Matlab you just need the below code:

clear all;

%window problem

syms r h area(h,r);
area = h*r*2 + pi*r*r/2;%first eq
length = 2*h+2*r+pi*r;%second eq
h = solve( 12== 2*h+2*r+pi*r,h)
solve(diff(subs(area)) ==0)

Here the length of the timers is 12 meters.  “syms” command define the r ,h and area as symbolic variables. Then we define the area and length. In the next step we determine “h” from the second equation. “subs” will substitute the determined h in area and the differential of the result equation should be solved.

Here we discussed a simple optimization problem. Also the Matlab code has discussed. If you had any problem feel free and send me your questions. Thanks!