Error using inlineeval, Error in inline/subsref, Newton method HELP!
이전 댓글 표시
ok so, As part of a group project, we have collected data that should allow us to 'triangulate' via newtons method the position of a fourth point. we are new to matlab, but the code used is from online instruction and we cannot see how to fix the issue, the number arent great, all were really looking for is a solution and an explanation of where we went wrong
% newton
format long
options = optimset('Jacobian','on');
n=12 % no of iterations
f = inline('[x(1)^2-1191.770*x(1)+x(2)^2-287.428*x(2)+x(3)^2-11.996*x(3)+406526.4166 ; x(1)^2-913.486*x(1)+x(2)^2-34.136*x(2)+x(3)^2-21.492*x(3)+231968.6664 ; x(1)^2-562.932*x(1)+x(2)^2-123.848*x(2)+x(3)^2-17.6742*x(3)+113459.6014]'); % original equations
Df = inline('[2*x(1)-1191.770, 2*x(2)-287.428, 2*x(3)-11.996 ; 2*x(1)-913.486, 2*x(2)-34.136, 2*x(3)-21.492 ; 2*x(1)-562.932, 2*x(2)-123.848, 2*x(3)-14.6742]'); % partial differentials
x = [1200;1200]
for i = 1:n
Dx = -Df(x)\f(x); %solve for increment
x = x + Dx; %add on for new guess
f(x) %see if f(x) is zero
end
there are comments so you can hoipefully follow our logic, thanks in advance for any help
these are the error codes
Error using inlineeval (line 15) Error in inline expression ==> [2*x(1)-1191.770, 2*x(2)-287.428, 2*x(3)-11.996 ; 2*x(1)-913.486, 2*x(2)-34.136, 2*x(3)-21.492 ; 2*x(1)-562.932, 2*x(2)-123.848, 2*x(3)-14.6742] Index exceeds matrix dimensions.
Error in inline/subsref (line 24) INLINE_OUT_ = inlineeval(INLINE_INPUTS_, INLINE_OBJ_.inputExpr, INLINE_OBJ_.expr);
Error in gps (line 9) Dx = -Df(x)\f(x); %solve for increment
답변 (2개)
Sean de Wolski
2013년 2월 27일
0 개 추천
Don't use inline. Use anonymous functions:
Dylan
2013년 2월 27일
편집: Sean de Wolski
2013년 2월 27일
댓글 수: 2
Dylan
2013년 2월 27일
Sean de Wolski
2013년 2월 27일
The matrix dimensions not agreeing means that you have two matrices that aren't the sizes you expect. Run:
dbstop if error
and then run your code. MATLAB will stop with the debugger and you will be able to identify the two variables that don't agree.
The other error indicates you're missing a parenthesis, bracket or brace.
카테고리
도움말 센터 및 File Exchange에서 Scope Variables and Generate Names에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!