Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

Incorrect

100Size
Leading solution size is 72.
This solution is locked. To view this solution, you need to provide a solution of the same size or smaller.

Test Suite

Test
Code Input and Output
1
Fail
 
%% Haftka & Gurdal, Figure 5.7.1 example
f = @(x) 0.5*x;
g = @(x) 2-x;
x0 = 5;
[xmin,fmin]=sumt_interior(f,g,x0) %#ok<*NOPTS>
xcorrect=2;
assert(norm(xmin-xcorrect)<2e-3)
assert(abs(fmin-f(xcorrect))<1e-3)
Error: Unrecognized parameter name 'Largescale'.  Please see the optimset reference page in the documentation for a list of acceptable option parameters. Link to reference page.
2
Fail
 
%%
f = @(x) 0.5*x;
g = @(x) 2-x;
x0 = 5;
[xmin,fmin]=sumt_interior(f,g,x0,1) % 1 iteration for unit penalty value
xr1=4;
assert(norm(xmin-xr1)<1e-4)
assert(abs(fmin-f(xr1))<1e-4)
Error: Unrecognized parameter name 'Largescale'.  Please see the optimset reference page in the documentation for a list of acceptable option parameters. Link to reference page.
3
Fail
 
%% Vanderplaats, Figure 5-4 example
f = @(x) sum(x);
g = @(x) [x(1) - 2*x(2) - 2
          8 - 6*x(1) + x(1).^2 - x(2)];
x0 = [3; 3];
[xmin,fmin]=sumt_interior(f,g,x0,1) % 1 iteration
xr2=[1.8686
     2.1221];
assert(norm(xmin-xr2)<1e-2)
assert(abs(fmin-f(xr2))<1e-2)
Error: Unrecognized parameter name 'Largescale'.  Please see the optimset reference page in the documentation for a list of acceptable option parameters. Link to reference page.
4
Fail
 
%%
f = @(x) sum(x);
g = @(x) [x(1) - 2*x(2) - 2
          8 - 6*x(1) + x(1).^2 - x(2)];
x0 = [2.1; 0.1];
r  = 2^12;
[xmin,fmin]=sumt_interior(f,g,x0,r) % Final iteration
xcorrect=[2; 0];
assert(norm(xmin-xcorrect)<5e-3)
assert(abs(fmin-f(xcorrect))<2e-3)
Error: Unrecognized parameter name 'Largescale'.  Please see the optimset reference page in the documentation for a list of acceptable option parameters. Link to reference page.