Drexel dragonThe Math ForumDonate to the Math Forum



Search All of the Math Forum:

Views expressed in these public forums are not endorsed by Drexel University or The Math Forum.


Math Forum » Discussions » Software » comp.soft-sys.matlab

Topic: Newton Raphson for nxn system using symbolic toolbox
Replies: 7   Last Post: Nov 16, 2011 5:09 AM

Advanced Search

Back to Topic List Back to Topic List Jump to Tree View Jump to Tree View   Messages: [ Previous | Next ]
Uwe Brauer

Posts: 83
Registered: 12/7/04
Re: Newton Raphson for nxn system using symbolic toolbox
Posted: Nov 15, 2011 5:15 AM
  Click to see the message monospaced in plain text Plain Text   Click to reply to this topic Reply

Christopher Creutzig <Christopher.Creutzig@mathworks.com> wrote in message <4EC235EE.9040108@mathworks.com>...
> On 11.11.11 16:17, Uwe Brauer wrote:
>

> > I can perfectly write matlab code for solving Newton Raphson for any nxn system, since Matlab uses dynamic memory,
> > and I have to use as a entry variable the system I want to solve and its jacobian.
> >
> > However when i only want to have the system and use Matlabs symbolic tool to calculate the jacobian I do not know how to do that since I don't know the size of the jacobian in advance.

>
> I still don't understand the problem. Something like the following
> sketch should work, no?
>
> ...
> J = jacobian(expression, vars);
> ...
> % within some loop:
> ...
> Fval = double(subs(expression, vars, values));
> Jac = double(subs(J, vars, values));
> ...
>
>
>
> Christopher


right, after thinking about it I came up with a similar solution,
BTW why do you use double?

function xvec=newtoniteratesymb(f,e,x0,TOL,nmax)

n=x0;
fev=subs(f,e,n);
jac=jacobian(f,e);
jacev=subs(jac,e,n);
xvec=x0;
k=1;
diff=100;

while diff>TOL & k<nmax
fev=subs(f,e,xvec(:,k));
jacev=subs(jac,e,xvec(:,k));
xvec(:,k+1)=xvec(:,k)- jacev\fev;
diff=max(max(xvec(:,k+1)-xvec(:,k)));
k=k+1;
end

thanks

Uwe



Point your RSS reader here for a feed of the latest messages in this topic.

[Privacy Policy] [Terms of Use]

© Drexel University 1994-2014. All Rights Reserved.
The Math Forum is a research and educational enterprise of the Drexel University School of Education.