Docsity

Steepest Descent 1-Numerical Analysis-MATLAB Code, Exercises of Mathematical Methods for Numerical Analysis and Optimization

Toggle sidebar
bg1
function [res] = CF(I,M,V,s)
% This function is used by Steepest Descent (Algorithm 10.3)
% define the component functions.
if M == 2
g = inline(s(I),'y1','y2');
res = g(V(1),V(2));
elseif M == 3
g = inline(s(I),'y1','y2','y3');
res = g(V(1),V(2),V(3));
elseif M == 4
g = inline(s(I),'y1','y2','y3','y4');
res = g(V(1),V(2),V(3),V(4));
elseif M == 5
g = inline(s(I),'y1','y2','y3','y4','y5');
res = g(V(1),V(2),V(3),V(4),V(5));
elseif M == 6
g = inline(s(I),'y1','y2','y3','y4','y5','y6');
res = g(V(1),V(2),V(3),V(4),V(5),V(6));
else
g = inline(s(I),'y1','y2','y3','y4','y5','y6','y7');
res = g(V(1),V(2),V(3),V(4),V(5),V(6),V(7));
end;
docsity.com

Partial preview of the text

Download Steepest Descent 1-Numerical Analysis-MATLAB Code and more Exercises Mathematical Methods for Numerical Analysis and Optimization in PDF only on Docsity!

function [res] = CF(I,M,V,s) % This function is used by Steepest Descent (Algorithm 10.3) % define the component functions. if M == 2 g = inline(s(I),'y1','y2'); res = g(V(1),V(2)); elseif M == 3 g = inline(s(I),'y1','y2','y3'); res = g(V(1),V(2),V(3)); elseif M == 4 g = inline(s(I),'y1','y2','y3','y4'); res = g(V(1),V(2),V(3),V(4)); elseif M == 5 g = inline(s(I),'y1','y2','y3','y4','y5'); res = g(V(1),V(2),V(3),V(4),V(5)); elseif M == 6 g = inline(s(I),'y1','y2','y3','y4','y5','y6'); res = g(V(1),V(2),V(3),V(4),V(5),V(6)); else g = inline(s(I),'y1','y2','y3','y4','y5','y6','y7'); res = g(V(1),V(2),V(3),V(4),V(5),V(6),V(7)); end;

docsity.com