Unrecognized function or variable 'seccionAurea'.

1 Ansicht (letzte 30 Tage)
ataberk kaplica
ataberk kaplica am 21 Dez. 2020
Beantwortet: Tarunbir Gambhir am 24 Dez. 2020
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

Antworten (1)

Tarunbir Gambhir
Tarunbir Gambhir am 24 Dez. 2020
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.

Kategorien

Mehr zu Startup and Shutdown finden Sie in Help Center und File Exchange

Produkte


Version

R2020b

Community Treasure Hunt

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

Start Hunting!

Translated by