cartpend_check_m - Sheet1 Page 1 function cartpend_check

Info iconThis preview shows pages 1–3. Sign up to view the full content.

View Full Document Right Arrow Icon

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: Sheet1 Page 1 function cartpend_check SolveOrdinaryDifferentialEquations % File cartpend_check.m created by Autolev 4.1 on Sun Nov 23 22:44:08 2008 %=========================================================================== function VAR = ReadUserInput global c c1 c2 g h IB k1 k2 MA MB FC TC global q1 q2 u1 u2 WCHECK1 global FA TAB q1p q2p u1p u2p WCHECK1p Check_AB L_AB_N1 NRG_AB global DEGtoRAD RADtoDEG global TINITIAL TFINAL INTEGSTP PRINTINT ABSERR RELERR %-------------------------------+--------------------------+-------------------+----------------- % Quantity | Value | Units | Description %-------------------------------|--------------------------|-------------------|----------------- c = c1 = c2 = g = 9.8 h = 0.5 IB = 0.5 k1 = 1 k2 = 2 MA = 5 MB = 2 FC = TC = q1 = q2 = 3 u1 = 0.5 u2 = WCHECK1 = 0.0 TINITIAL = TFINAL = 50 INTEGSTP = 0.1 PRINTINT = 1 ABSERR = 1.0E-08 RELERR = 1.0E-08 %-------------------------------+--------------------------+-------------------+----------------- % Unit conversions Pi = 3.141592653589793 DEGtoRAD = Pi/180.0 RADtoDEG = 180.0/Pi q2 = q2*DEGtoRAD % Evaluate constants % Set the initial values of the states VAR(1) = q1 Sheet1 Page 2 VAR(2) = q2 VAR(3) = u1 VAR(4) = u2 VAR(5) = WCHECK1 %=========================================================================== function OpenOutputFilesAndWriteHeadings FileIdentifier = fopen('cartpend_check.1', 'wt') fprintf( 1, '%% t q1 q2\n' ) fprintf( 1, '%% (s) (m) (deg)\n\n' ) fprintf(FileIdentifier, '%% FILE: cartpend_check.1\n%%\n' ) fprintf(FileIdentifier, '%% t q1 q2\n' ) fprintf(FileIdentifier, '%% (s) (m) (deg)\n\n' ) FileIdentifier = fopen('cartpend_check.2', 'wt') fprintf(FileIdentifier, '%% FILE: cartpend_check.2\n%%\n' ) fprintf(FileIdentifier, '%% t L_AB_N1 NRG_AB Check_AB\n' ) fprintf(FileIdentifier, '%% (s) (UNITS) (UNITS) (UNITS)\n\n' ) %=========================================================================== % Main driver loop for numerical integration of differential equations %=========================================================================== function SolveOrdinaryDifferentialEquations global c c1 c2 g h IB k1 k2 MA MB FC TC global q1 q2 u1 u2 WCHECK1 global FA TAB q1p q2p u1p u2p WCHECK1p Check_AB L_AB_N1 NRG_AB...
View Full Document

Page1 / 15

cartpend_check_m - Sheet1 Page 1 function cartpend_check

This preview shows document pages 1 - 3. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online