Unrecognized function or variable 'seccionAurea'.

function powellmethod
max=0;
f=@(x1,x2) 25*(x1)^2+2.5*(x2)^2+15*(x1)*(x2)-25*(x1)-10*(x2);
grad={@(x1,x2) 50*(x1)+15*(x2)-25; @(x1,x2) 5*(x2)+15*(x1)-10};
x0=[2;2];
tol=0.045;
Maxiter=100;
bk=5;
n=size(x0,1);
iter=1;
D=eye(n);
y1=x0;
k=1;
j=1;
d=zeros(n,1);
alpha=0;
Fgrad=[grad{1}(y1(1),y1(2)); grad{2}(y1(1),y1(2)) ] ;
Da(iter,:)={iter, x0 , d ,alpha,Fgrad,x0};
iter=iter+1;
while norm(Fgrad)>tol && iter<=Maxiter
d=-D*Fgrad;
[alpha]=seccionAurea(f,x0,d,bk,max)
x1=x0+alpha*d;
y1=x1;
Fgrad=[grad{1} y1(1) ,y1(2);
grad{2} y1(1),y1(2)];
Da(iter,:)={iter,x0 , d , alpha , Fgrad, x1};
x0=x1;
if norm(Fgrad)<tol
break
end
p=Da{iter,4}*Da{iter,3};
q=Da{iter,5}*Da{iter-1,5};
D=D+((p*p')/(p'*q))-((D*q*q'*D)/(q'*D*q));
iter=iter+1;
end
code gives error when run it , same code work in my teacher laptop but gives me an error ,code is %100 same with teacher

Réponses (1)

On your teachers machine, use "which" function to locate where the function "seccionAurea" is defined.
which seccionAurea
Make sure that this file is on the MATLAB path for your machine. Refer to this question for how to set path for user defined functions.

Catégories

En savoir plus sur Animation dans Centre d'aide et File Exchange

Produits

Version

R2020b

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by