OSU ENGR H192 - Lecture 20 - Propulsion Lab with MATLAB

Unformatted text preview:

Propulsion Lab with MATLABRecording a Session With the MATLAB Diary CommandPropulsion Lab Data Reduction with MATLABSlide 4Slide 5Slide 6Sample Plot From Rocket Motor TestExtracting a Sub-MatrixExtracting a Sub-VectorSumming the Elements of a Vector or MatrixExamining Plots With the MATLAB Axis CommandSelecting Coordinates from Plots With the MATLAB Ginput CommandLect 20 P. 1 Engineering H192 - Computer Programming Winter QuarterThe Ohio State UniversityGateway Engineering Education CoalitionPropulsion Lab with MATLABLecture 20Lect 20 P. 2 Engineering H192 - Computer Programming Winter QuarterThe Ohio State UniversityGateway Engineering Education CoalitionRecording a Session With the MATLAB Diary Command•MATLAB provides a diary feature to capture the text from a MATLAB session in an ASCII text file. •The commands to use it are:–>> diary filename % Start a diary–>> diary % Toggles diary on/off–>> diary on % Activates diary–>> diary off % Suspends diaryLect 20 P. 3 Engineering H192 - Computer Programming Winter QuarterThe Ohio State UniversityGateway Engineering Education CoalitionPropulsion Lab Data Reduction with MATLAB•Algorithm–Use a text editor to open the data file, remove the header lines and save the file.–Start MATLAB. Select working directory if appropriate.–Start a diary. Thereafter, turn on or off as appropriate.–Load the data file.–Display the matrix to determine what column to use for the thrust vector.Lect 20 P. 4 Engineering H192 - Computer Programming Winter QuarterThe Ohio State UniversityGateway Engineering Education CoalitionPropulsion Lab Data Reduction with MATLAB–Create thrust vector.–Plot thrust vector against its index.–Examine the plot to determine:•index when “burn” starts•index when “burn” ends•index when retro fires to deploy chute–Create “burn_thrust” sub-vector using elements of thrust vector between “burn start” index and “burn end” indexLect 20 P. 5 Engineering H192 - Computer Programming Winter QuarterThe Ohio State UniversityGateway Engineering Education CoalitionPropulsion Lab Data Reduction with MATLAB–Calculate impulse by calculating area under plot curve between “burn start” and “burn end”. –To do this, multiply each element of “burn” sub-vector by sampling period and thrust stand's calibration factor.Lect 20 P. 6 Engineering H192 - Computer Programming Winter QuarterThe Ohio State UniversityGateway Engineering Education CoalitionPropulsion Lab Data Reduction with MATLAB–Examine raw data at ends of “burn” sub-vector to determine whether pre-burn values were actually zero. –If they were not, some "weight" was counted as thrust. Subtract appropriate amount from impulse.Lect 20 P. 7 Engineering H192 - Computer Programming Winter QuarterThe Ohio State UniversityGateway Engineering Education CoalitionSample Plot From Rocket Motor Test0 50 100 150 200 250 300 350 400-0.500.511.522.5Lect 20 P. 8 Engineering H192 - Computer Programming Winter QuarterThe Ohio State UniversityGateway Engineering Education CoalitionExtracting a Sub-Matrix•A portion of a matrix can be extracted and stored in a smaller matrix by specifying the names of both matrices and the rows and columns to extract. The syntax is: sub_matrix = matrix ( r1 : r2 , c1 : c2 ) ; where r1 and r2 specify the beginning and ending rows and c1 and c2 specify the beginning and ending columns to use for the new matrix.Lect 20 P. 9 Engineering H192 - Computer Programming Winter QuarterThe Ohio State UniversityGateway Engineering Education CoalitionExtracting a Sub-Vector•In a similar fashion as with a matrix, a sub-vector can be created using elements m through n of an existing vector as follows:my_sub_vector = my_vector ( m : n ) ;Lect 20 P. 10 Engineering H192 - Computer Programming Winter QuarterThe Ohio State UniversityGateway Engineering Education CoalitionSumming the Elements of a Vector or Matrix•All the elements of a vector can be added up using the sum command as follows:total = sum ( my_sub_vector) ;•All the columns of a matrix may be summed with the command:total_vector = sum (my_matrix) ;It returns a vector containing the sums of each column. That can then be summed to sum the entire matrix.Lect 20 P. 11 Engineering H192 - Computer Programming Winter QuarterThe Ohio State UniversityGateway Engineering Education CoalitionExamining Plots With the MATLABAxis Command•MATLAB plots are created with default axes that display the entire plot. An axis command can be used after the plot is created to “zoom in” on a portion of the plot. The command is: axis ( [ x1 x2 y1 y2 ] ) ; Where x1 and x2 are the x-axis min and max values and y1 and y2 are the y-axis values to use.•The axis command can be used repeatedly to display various portions of the plot.Lect 20 P. 12 Engineering H192 - Computer Programming Winter QuarterThe Ohio State UniversityGateway Engineering Education CoalitionSelecting Coordinates from Plots With the MATLAB Ginput Command•The coordinates of points on a plot can be input into MATLAB using the function ginput. The syntax is:[ x, y ] = ginput ( n ) ;•It places a full-window, mouse-able cross-hair on the plot and the user can select n points. The•x-coordinates of the points are stored in the vector x and the y-coordinates in the vector


View Full Document

OSU ENGR H192 - Lecture 20 - Propulsion Lab with MATLAB

Documents in this Course
Strings

Strings

22 pages

Load more
Download Lecture 20 - Propulsion Lab with MATLAB
Our administrator received your request to download this document. We will send you the file to your email shortly.
Loading Unlocking...
Login

Join to view Lecture 20 - Propulsion Lab with MATLAB and access 3M+ class-specific study document.

or
We will never post anything without your permission.
Don't have an account?
Sign Up

Join to view Lecture 20 - Propulsion Lab with MATLAB 2 2 and access 3M+ class-specific study document.

or

By creating an account you agree to our Privacy Policy and Terms Of Use

Already a member?