Info

이 질문은 마감되었습니다. 편집하거나 답변을 올리려면 질문을 다시 여십시오.

Why Error in while loop?

조회 수: 1 (최근 30일)
Shantanu K
Shantanu K 2013년 4월 2일
x10=2;
x20=-2;
x30=1;
e1=0.00001;
iter=10;
m=2;
z = sym('2*x1 * x1 + x2*x2 + 3*x3*x3');
syms x1 x2 x3 a;
gradz = -[diff(z,x1); diff(z,x2); diff(z,x3)]; % returns a column vector
p=subs(gradz, [x1 x2 x3], [x10 x20 x30]); % evaluate at (0.25, 0.75)
x1a0=x10+a*p(1);
x2a0=x20+a*p(2);
x3a0=x30+a*p(3);
za0=subs(z, [x1 x2 x3], [x1a0 x2a0 x3a0]);
dza0=diff(za0,a);
k=solve(dza0);
x11=vpa(x10+k*p(1),8);
x21=vpa(x20+k*p(2),8);
x31=vpa(x30+k*p(3),8);
cltr1=((x11-x10)/x10);
while ((m<iter) && (cltr1>e1))
m=m+1;
p=subs(gradz, [x1 x2 x3], [x11 x21 x31]);
x1a=x11+p(1)*a;
x2a=x21+p(2)*a;
x3a=x31+p(3)*a;
za1=subs(z, [x1 x2 x3], [x1a x2a x3a]);
dza1=diff(za1,a);
w=solve(dza1);
x12=x11+p(1)*w;
x22=x21+p(2)*w;
x32=x31+p(3)*w;
x1k=x11;
x2k=x21;
x3k=x31;
x11=x12;
x21=x22;
x31=x32;
end
display(x12)
display(x22)
display(x32)
There is error in executing while command. Error is as follow: ??? Error using ==> sym.sym>notimplemented at 2514 Function 'gt' is not implemented for MuPAD symbolic objects.
Error in ==> sym.sym>sym.gt at 792 notimplemented('gt');
Error in ==> CAUCHY_1 at 28 while ((m<iter) && (cltr1>0.001))

답변 (0개)

이 질문은 마감되었습니다.

Community Treasure Hunt

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

Start Hunting!

Translated by