- #1
Kruum
- 220
- 0
Homework Statement
Our assignement is to fix an .m file, which should produce Newton's method for a function. I'm very new to Matlab and some expressions are weird to me.
The Attempt at a Solution
So I've got the code to look like this:
Code:
function point=teemuNewton(xbeg, ybeg, iternmbr)
iternmbr=10;
X=zeros(2,iternmbr);
xbeg=X(1,1);
ybeg=X(1,2);
for roun=2:iternmbr;
x=X(1,roun-1);
y=X(2,roun-1);
X(:,roun)= X(:,roun-1)-inv([8*y 2*x ; 2*x-2*y -2*x+18*y])*[x^2+4*y^2-13, x^2-2*x*y+9*y^2-17];
end
point=X(:,iternmbr)
Every time I tr to run it I get a warning:
? Error using ==> mtimes
Inner matrix dimensions must agree.
Error in ==> teemuNewton at 11
X(:,roun)= X(:,roun-1)-inv([8*y 2*x ; 2*x-2*y -2*x+18*y])*[x^2+4*y^2-13,
x^2-2*x*y+9*y^2-17];
What does the first error mean? And how should I define the X matrix?
Last edited: