Menu

output not changing

2021-04-05
2021-04-06
  • Vaishali Patne

    Vaishali Patne - 2021-04-05

    I am trying to implement simple 2 state system of simple pendulum. though the x2 values are correct, the x1 is not changing at all. its a straight line with 0 values. what can be possible reasons.

    I am using codeblock to run the c code and then plot the graph in matlab.

    out[0] = x[2];
    out[1] = (-98.1)*sin(x[1]) - 0.2*x[2] + u[0];
    
     
  • Andreas Völz

    Andreas Völz - 2021-04-05

    Hello Vaishali,

    did you consider that array indices start with zero in C code? If the states x are position and velocity, then you probably want

    out[0] = x[1];
    out[1] = -98.1 * sin(x[0]) - 0.2 * x[1] + u[0]
    

    Otherwise, what is x[0], x[1], x[2] and why is there no out[2]?

    Regards,
    Andreas

     
  • Vaishali Patne

    Vaishali Patne - 2021-04-06

    There are only 2 states x(0) and x(1) . There is no x(2) - hence only out0 which is x0_dot and out1 which is x1_dot

     
  • Andreas Völz

    Andreas Völz - 2021-04-06

    Is the problem solved if you use the correct indices x[0] and x[1]? Otherwise, I need more information, e.g. the complete probfct.

     
  • Vaishali Patne

    Vaishali Patne - 2021-04-06

    yes yes - solved -- thanks a lot for pointing out the basic error

     

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.