j134org.m
来自「很实用的在matlab环境下的图像处理源程序代码」· M 代码 · 共 35 行
M
35 行
function [z,gz,hz] = j134org(x,varargin)
% example 13.4 of Optimization of Chemical Processes.
% x = [c1 c2 c3 ... r1 r2 r3 ... theta1 theta2 theta3 ...]'
%
% Calculating the criterion z (output concentration from last reactor)
% and eventually its 1. and 2. derivatives with respect to x
[m,n]=size(x);
% fprintf(1,'%7.4f %7.4f %7.4f %7.4f %7.4f %7.4f %7.4f %7.4f %7.4f \n',x);
tanks=m/3;
% scaling
en=ones(1,tanks);
xscaling=diag([ en 0.01*en 100*en]);
x = xscaling*x;
% end scaling
z=x(m/3,:); % output concentration from last reactor
if nargout > 1
gz=zeros(1,m); % gradient
gz(1,m/3)=1;
gz = xscaling * gz'; % scale and transpose
end
if nargout > 2
hz=zeros(m,m); % hessian
hz = xscaling * hz * xscaling; % scale
end
return
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?