The Math Forum

Search All of the Math Forum:

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

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

Notice: We are no longer accepting new posts, but the forums will continue to be readable.

Topic: derivatives, syms and fsolve
Replies: 5   Last Post: Jul 22, 2013 1:27 PM

Advanced Search

Back to Topic List Back to Topic List Jump to Tree View Jump to Tree View   Messages: [ Previous | Next ]
Andrea Asoni

Posts: 10
Registered: 4/15/09
derivatives, syms and fsolve
Posted: Jul 28, 2009 6:59 PM
  Click to see the message monospaced in plain text Plain Text   Click to reply to this topic Reply

I would like to define a function, take derivatives of this function and then solve the system of equations formed by putting these derivatives equal to zero. A simplified version of my problem is:
age =[12 13 14 15]; age=age';
sex =[1 1 0 0]; sex=sex';

syms a b;
lik= (a^2)*b.*age + (1/b).*sex

da=diff(lik,a); db=diff(lik,b)
D=[da; db]

x=[a b]
fun=@(x) D

init=[1 2]

when I run this it gives me the error: "??? Conversion to double from sym is not possible."

I tried to add after "D=[da;db]" the line "D=double(D)" but it gives me another error "Error using ==> eval
Undefined function or variable 'a'."

I tried the function "double" in different places (on x, on D, on fun) but it always gives me an error message.

Anyone knows how to deal with this problem? How do I take derivatives and then solve the system?

Any help is very appreciated,

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

[Privacy Policy] [Terms of Use]

© The Math Forum at NCTM 1994-2018. All Rights Reserved.