How can I evaluate Jacobian matrix?

5 vues (au cours des 30 derniers jours)
Alberto
Alberto le 20 Jan 2013
I have a problem. I made a program for "Newton-Raphson method for vectorial function" but I have a problem. Let's suppose to have the function f(x,y)=(x-y,x+y^2). The jacobian matrix is [1,-1;1,2*y]. Then I put r=symvar(jacobian) and to evaluate I use subs(jacobian,r,x0): So my problem is: how can I evaluate the matrix in x0=(0,0) if the first variable x doesn't appear?
Here it is my Matlab code:
function [ x0,iter ] = newtonvect( f1,x0,tol,imax )
%UNTITLED3 Summary of this function goes here
% Detailed explanation goes here
f2=sym(f1);
t=symvar(f2);
j=jacobian(f1,t);
r=symvar(j);
val=subs(f1,t,x0);
m=length(r);
iter=0;
while norm(val)>tol & iter<imax
*x1=x0(1:m);*
jac=subs(j,r,x1);
z=Gausselpiv(jac,-val);
x0=x0+z';
iter=iter+1;
val=subs(f1,t,x0);
end
Obviously bold line is wrong and the code does not work in every case.Could you help me please?

Réponses (0)

Community Treasure Hunt

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

Start Hunting!

Translated by