Code covered by the BSD License

# Files for the 2012 Webinar "Tips and Tricks - Getting Started Using Optimization with MATLAB"

### Seth DeLand (view profile)

These are the files that were used for the demonstrations in the webinar.

VEOptimization.m
```%% Engine Analysis - Maximize Volumetric Efficiency
% Compare the one-factor-at-a-time approach with an optimization solver.

% Copyright (c) 2012, The MathWorks, Inc.
%% Initial Guess at Parameters
RPM = 3.5; % Engine speed/1000
Pratio = 0.5;
VolumEff = VEMap([RPM Pratio])                                             %#ok<*NOPTS,*NASGU>

%% Increase Pressure Ratio
RPM = 3.5;
Pratio = 0.6;
VolumEff = VEMap([RPM Pratio])

%% Increase Pressure Ratio
RPM = 3.5;
Pratio = 0.7;
VolumEff = VEMap([RPM Pratio])

%% Increase Pressure Ratio
RPM = 3.5;
Pratio = 0.8;
VolumEff = VEMap([RPM Pratio])

%% Decrease Pressure Ratio
RPM = 3.5;
Pratio = 0.75;
VolumEff = VEMap([RPM Pratio])

%% Decrease Engine Speed
RPM = 3.0;
Pratio = 0.75;
VolumEff = VEMap([RPM Pratio])

%% Increase Engine Speed
RPM = 4.0;
Pratio = 0.75;
VolumEff = VEMap([RPM Pratio])

%% Use Optimization Solver FMINUNC
objFcn = @(x) -VEMap(x);
x0 = [3.5 0.5];
lb = [1.0 0];
ub = [6.0 1.0];
options = optimset('Algorithm','interior-point','Disp','iter');
[xOpt, fVal] = fmincon(objFcn, x0,[],[],[],[],lb,ub,[],options);

%% Display Results
fprintf('Engine Speed:         \t%4.0f RPM\n',1000*xOpt(1));
fprintf('Pressure Ratio:       \t%4.3f\n',xOpt(2));
fprintf('Volumetric Efficiency:\t%4.3f\n\n',-fVal);
```