Dismiss Notice
Join Physics Forums Today!
The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

Matlab follow path

  1. Sep 22, 2011 #1
    Hi im trying to figure out matlab control system stuff a little more, what would be the best way to go about in 2d having a point with all the equations of motion inputed for direction and distance try to follow a set path like 10 ft forward from (0,0) and turning 90 degrees right and going another 10 ft, to see how accurate the equations of motion can make the path. Thanks
     
  2. jcsd
  3. Sep 23, 2011 #2

    uart

    User Avatar
    Science Advisor

    Hi Paul. Do you have simulink or are you talking about plain old matlab to do this?
     
  4. Sep 23, 2011 #3
    matlab, i wouldnt be opposed to using simulink to do it. I just have never used simulink. Would simulink be better for this?
     
  5. Sep 23, 2011 #4

    uart

    User Avatar
    Science Advisor

    Yes you can do it with just matlab.

    Say you had a simple system like just moving a mass from x=0 to x=1 with a linear actuator that could provide a force on the mass in response to some "control law". Are you familiar with how to derive a differential equation for the motion of the mass?

    For example lets say we have a simple proportional control law, where the actuator provides a force that is proportional (and opposite) to the error in the current x position of the mass.

    Do you know how to make an ODE (ordinary differential equation) for that system?
     
  6. Sep 23, 2011 #5
    Like PID? No I havent set one up before but I am reading up on it. How would I use my 2nd order ode's into the pid?
     
  7. Sep 23, 2011 #6

    uart

    User Avatar
    Science Advisor

    Ok here's a simple example. Say you had the simple system (just moving a mass) :
    [tex] \ddot{x} = \frac{F}{m} [/tex]

    And you use the control law.
    [tex] F = -k_p(x - x_d) [/tex]

    Combine the equations to make the DE.
    [tex] \ddot{x} = \frac{k_p}{m} (x_d - x) [/tex]

    And just for a simple example let's make all the parameters unity.
    [tex] \ddot{x} = (1 - x) [/tex]

    To use matlabs ODE solvers you need to represent the states as a vector. I'll use x(1) for x and x(2) for velocity, [itex]\dot{x}[/itex].

    [tex]\tilde{x} = [x\, ; \, \dot{x} ] [/tex]

    Then you can use one of the ODE solvers (I prefer "ode45") to solve the equation and make a plot of the output response.
     
Know someone interested in this topic? Share this thread via Reddit, Google+, Twitter, or Facebook




Similar Discussions: Matlab follow path
Loading...