Presentation is loading. Please wait. # Engineering H192 - Computer Programming Gateway Engineering Education Coalition Lect 20P. 1Winter Quarter Propulsion Lab with MATLAB Lecture 20.

## Presentation on theme: "Engineering H192 - Computer Programming Gateway Engineering Education Coalition Lect 20P. 1Winter Quarter Propulsion Lab with MATLAB Lecture 20."— Presentation transcript:

Engineering H192 - Computer Programming Gateway Engineering Education Coalition Lect 20P. 1Winter Quarter Propulsion Lab with MATLAB Lecture 20

Engineering H192 - Computer Programming Gateway Engineering Education Coalition Lect 20P. 2Winter Quarter Propulsion 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.

Engineering H192 - Computer Programming Gateway Engineering Education Coalition Lect 20P. 3Winter Quarter Propulsion 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” index

Engineering H192 - Computer Programming Gateway Engineering Education Coalition Lect 20P. 4Winter Quarter Propulsion 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. –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.

Engineering H192 - Computer Programming Gateway Engineering Education Coalition Lect 20P. 5Winter Quarter Sample Plot From Rocket Motor Test

Engineering H192 - Computer Programming Gateway Engineering Education Coalition Lect 20P. 6Winter Quarter Recording 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 and off >> diary on % Activates diary >> diary off % Suspends diary

Engineering H192 - Computer Programming Gateway Engineering Education Coalition Lect 20P. 7Winter Quarter Extracting 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.

Engineering H192 - Computer Programming Gateway Engineering Education Coalition Lect 20P. 8Winter Quarter Extracting 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 ) ;

Engineering H192 - Computer Programming Gateway Engineering Education Coalition Lect 20P. 9Winter Quarter Summing 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 = sum (my_matrix) ; It returns a vector containing the sums of each column. That can then be summed to sum the entire matrix.

Engineering H192 - Computer Programming Gateway Engineering Education Coalition Lect 20P. 10Winter Quarter Examining Plots With the MATLAB Axis 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.

Engineering H192 - Computer Programming Gateway Engineering Education Coalition Lect 20P. 11Winter Quarter Selecting 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 y.

Download ppt "Engineering H192 - Computer Programming Gateway Engineering Education Coalition Lect 20P. 1Winter Quarter Propulsion Lab with MATLAB Lecture 20."

Similar presentations

Ads by Google