Unrecognized function or variable 'seccionAurea'.
1 vue (au cours des 30 derniers jours)
Afficher commentaires plus anciens
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
0 commentaires
Réponses (1)
Voir également
Catégories
En savoir plus sur Startup and Shutdown dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!