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. Advertising

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. Ali

    How to use python in matlab

    Ali, Oct 30, 2004, in forum: Python
    Replies:
    3
    Views:
    4,026
    Fernando Perez
    Nov 4, 2004
  2. siki
    Replies:
    0
    Views:
    975
  3. dd
    Replies:
    1
    Views:
    313
    Richard Heathfield
    Apr 6, 2006
  4. Luna Moon
    Replies:
    16
    Views:
    1,354
    Giovanni Gherdovich
    Aug 8, 2008
  5. patmatp

    use vhdl program in matlab

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

Share This Page