use of odeset with matlab c++

Discussion in 'C++' started by shyam, Dec 5, 2006.

  1. shyam

    shyam Guest

    Hi,
    I am trying to use ode45 in c++ using the matlab library functions. I
    am trying to use a mass matrix using the odeset property. First i tried
    the code without setting a mass matrix. Here is a sample :
    options = odeset("RelTol",0.0001,"AbsTol",0.0001);
    .
    .
    t = ode45(&y,"rigid",tspan,y0,options);

    This part works and i get an answer but as soon as i try to introduce a
    mass matrix the code fails to execute:
    //function to integrate
    mwArray rigid(mwArray t,mwArray y)
    {
    mwArray dy;
    dy(1) = y(1); // a column vector
    return (dy);
    }

    //mass matrix
    mwArray massmat(mwArray t,mwArray y)
    {
    mwArray M;
    M(1,1) = 1; // a column vector
    return (M);
    }

    DECLARE_FEVAL_TABLE
    FEVAL_ENTRY(rigid);
    FEVAL_ENTRY(massmat);
    END_FEVAL_TABLE
    options = odeset("Mass","massmat","RelTol",0.0001,"AbsTol",0.0001);
    .
    .
    t = ode45(&y,"rigid",tspan,y0,options);

    Is there something wrong in the way that i refer to the function used
    in the mass matrix(massmat) ??
    Thanks in advance, shyam.
     
    shyam, Dec 5, 2006
    #1
    1. Advertisements

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. moe
    Replies:
    1
    Views:
    2,616
    Tom Hawkins
    Oct 26, 2003
  2. Ouadid
    Replies:
    7
    Views:
    10,941
    Jim Wu
    Dec 18, 2003
  3. Juan Carlos Allica
    Replies:
    0
    Views:
    1,270
    Juan Carlos Allica
    Jul 15, 2005
  4. Ali

    How to use python in matlab

    Ali, Oct 30, 2004, in forum: Python
    Replies:
    3
    Views:
    4,220
    Fernando Perez
    Nov 4, 2004
  5. siki
    Replies:
    0
    Views:
    1,221
  6. dd
    Replies:
    1
    Views:
    448
    Richard Heathfield
    Apr 6, 2006
  7. Luna Moon
    Replies:
    16
    Views:
    1,834
    Giovanni Gherdovich
    Aug 8, 2008
  8. patmatp

    use vhdl program in matlab

    patmatp, Aug 4, 2012, in forum: VHDL
    Replies:
    0
    Views:
    676
    patmatp
    Aug 4, 2012
Loading...