📄 fmin.m
字号:
% Sifei Liu
% SA08023001
% 4 Oct 2008
function [fx,fy,iter] = fmin(func, method)
% Find out the optimum point that minimize the function, using different
% approches:
% GoldSect: 黄金分割法;
% TrpInse: 三次插值法;
% Netow: 牛顿法;
% secant: 割线法;
% bisector: 平分线法;
% Tptwic:三点二次插值法;
% fx,fy is the final result,iter is the iteration time;
if nargin ~=2
error('error input number!');
end
switch method
case 'GoldSect',
limt1 = input('lower:');
limt2 = input('uper:');
[fx,fy,iter]=GoldSect(func,[limt1,limt2]);
case 'TrpInse'
limt1 = input('lower:');
limt2 = input('uper:');
[fx,fy,iter]=TrpInse(func,[limt1,limt2]);
case 'Tptwic'
a1 = input('The first point:');
a2 = input('The second point:');
a3 = input('The third point:');
[fx,fy,iter] = Tptwic(func, [a1,a2,a3]);
case 'Newton'
limt1 = input('lower:');
limt2 = input('uper:');
Ini = input('Initial:');
[fx,fy,iter]=Newton(func,Ini,[limt1,limt2]);
case 'secant'
limt1 = input('lower:');
limt2 = input('uper:');
[fx,fy,iter] = secant(func,[limt1,limt2]);
case 'bisector'
limt1 = input('lower:');
limt2 = input('uper:');
[fx,fy,iter] = bisector(func,[limt1,limt2]);
otherwise
error('Unknown method!')
end
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -