%% Function %% function xdot = xsystem_tilt(t,x) global P K1 K2 xd Vs Vco g theta Vc = Vco + K1*(x(1)-xd) + K2*(x(2)); % voltage on cart sphere [V] if Vc > 30000 Vc = 30000; elseif Vc < -30000 Vc = -30000; end %% Differential Equations %% xdot(1) = x(2); xdot(2) = Vs*Vc*P/((x(1))^2) - g*sin(theta); xdot = xdot';