disp('Optimized Parameters:'); disp(paramOpt); disp('Objective Function Value:'); disp(fval);
% Close the model
close_system(model, 0);
% Function to simulate the powertrain model
function cost = simulatePowertrain(model, param, paramNames) % Set the parameters in the model for i = 1:length(param) set_param([model '/' paramNames{i}], 'Value', num2str(param(i))); end