0% found this document useful (0 votes)
22 views1 page

SQRT Atan: Function Global G - CM K - CM M y - Pivot - Location String - Length C

This MATLAB function defines a system of differential equations that models the motion of a spring pendulum over time. It takes in the time and state vector, uses values from global variables to calculate the length and angle of the pendulum based on the x and y positions. It then returns the time derivatives of position and velocity based on spring force, gravity, and damping terms.

Uploaded by

rishanshawkat
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
22 views1 page

SQRT Atan: Function Global G - CM K - CM M y - Pivot - Location String - Length C

This MATLAB function defines a system of differential equations that models the motion of a spring pendulum over time. It takes in the time and state vector, uses values from global variables to calculate the length and angle of the pendulum based on the x and y positions. It then returns the time derivatives of position and velocity based on spring force, gravity, and damping terms.

Uploaded by

rishanshawkat
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 1

function [ dydz ] = spring_pendulum(t,z)

global g_cm k_cm m y_pivot_location string_length c


L = sqrt(z(1)^2 + (y_pivot_location - z(3))^2);
theta = atan(0 - z(1) / (y_pivot_location - z(3)));
dydz = [z(2);...
(k_cm/m) * (L - string_length) * sin(theta) - (c/m)*z(2);...
z(4);...
(k_cm/m) * (L - string_length) * cos(theta) + g_cm - (c/m)*z(4);];
end

You might also like