I can't figure out how to write equations of motion into Matlab.
9 次查看（过去 30 天）
I'm attempting to code a simulation for a hockey puck on a playground carousel which I have found the equations of motion for.
The equations are:
With m being the mass, omega (and theta dot) being the angular velocity, x being the distance from the puck to the center of the carousel, and v being the tangental velocity. Cf is the centrifugal velocity and Cp is the centripetal velocity.
I've been trying to utilize the ode45 function and directly writing down the equations to no avail. Can I get a nudge into the right direction? Any help would be greatly appreciated.
William Rose 2022-11-21
Please read the examples in ode45() help pages carefully, They are very helpful.
You have two angular velocities: ω and . Is ω a constant, the carousel rotation rate? Is Θ the time-varying angular position of the puck, in an inertial, i.e. non-rotating, reference frame?
You say v = tangential velocity. Is that in the non-rotating frame? Can you express v in terms of x and Θ, or in terms of and ?
You say Cp=centripetal velocity and Cf=centrifugal velocity. I think you meant to say Cp=centripetal force, etc.
You will need to write the equations of motin as a set of first order differential equations. I suspect you will need four variables: two equations for x and two for Θ. The vector y will have elements . I assume that you can write the velocity v as a function of x and theta.
You will need to create a derivative function which returns a 1x4 vector whose elements are . For example, your function could look like this:
m=1; w=1; %define constants
v=...; %define v as a constant, or in terms of components of y.
dy(4)=...; %fill in as appropriate
You will pass the name carousel to ode45(). Try it. Good luck.