필터 지우기
필터 지우기

Error: File: box.m Line: 23 Column: 21 Unbalanced or unexpected parenthesis or bracket.

조회 수: 2 (최근 30일)
function box(a,b,c)
tol=10^(-15);
X=[a;b;c];
Y=F(X);
disp(' n a b c |F(X)|');
n=0;
while (true)
changeX=-dF(X)\Y;
X=X+changeX;
Y=F(X);
n=n+1;
fprintf('%3d %21.15f %21.15f %21.15f %10.1e \n', n, X(1), X(2), X(3), norm(Y));
if norm(changeX) < tol*norm(X)
disp('Root Found'); break;
end
if n>=100
disp('Failed To Converge'); break;
end
end
end
function Y=F(X)
a=X(1); b=X(2); c=X(3);
Y = [a*b*c-181;2(a*b+a*c+b*c);a^2+b^2+c^2];
end
function J=dF(X)
a=X(1); b=X(2); c=X(3);
J=[bc,ac,ab;4b+4c,4a+4c,4a+4b;2a,2b,2c];
end

채택된 답변

Azzi Abdelmalek
Azzi Abdelmalek 2014년 1월 29일
편집: Azzi Abdelmalek 2014년 1월 29일
You missed a multiplication operator * in (line 23)
Y = [a*b*c-181;2(a*b+a*c+b*c);a^2+b^2+c^2];
It should be
Y = [a*b*c-181;2*(a*b+a*c+b*c);a^2+b^2+c^2];

추가 답변 (1개)

Cagas Akalin
Cagas Akalin 2015년 4월 15일
Hi everyone,
Matlab gives the same error for the below line code because of the script in first parenthesis. - (1-x1.)^2-
If you know how to correct it, please share your suggestion...
f = @(x1,x2) (1-x1.)^2+100*(x2.-x1.^2)^2

카테고리

Help CenterFile Exchange에서 Get Started with MATLAB에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by