Download Importing and Exporting ASCII Data Files in MATLAB for Geosystems Engineering Students and more Study Guides, Projects, Research Engineering in PDF only on Docsity! SOLUTION SET Computer Project No. 5 February 19, 2004 Due on February 24, 2004, 9:30 AM PGE310 (Unique No. 17235) Spring Semester 2004 Formulation and Solution of Geosystems Engineering Problems Instructor: Carlos T. Verdín IMPORTING AND EXPORTING ASCII DATA FILES INTO MATLAB AND DATA MANIPULATION DESCRIPTION: This computer project is intended to introduce to the use of simple Matlab commands used to import and export ASCII data files. You will be provided with an Excel file that contains time records of pressure and temperature acquired in an active hydrocarbon field. The objective is to import those data into Matlab for plotting and further processing. YOUR REPORT SHOULD BE CLEAN, NEAT, AND WELL ORGANIZED; IT SHOULD INCLUDE CLEAR AND COMPLETE TECHNICAL DESCRIPTIONS WHEREVER NECESSARY. ALL FIGURES AND TABLES SHOULD BE LABELED AND PROPERLY ANNOTATED WITH A CAPTION. LOOSE FIGURES ARE NOT SELF- EXPLANATORY. POINTS WILL BE DEDUCTED FROM PROJECTS THAT DOES NOT ADHERE TO THESE PRESENTATION RULES. TASKS: (1) Download the Excel data file posted on the course web site. Inspect the contents of this file. You should be able to recognize columns for time, pressure, and temperature. Pay special attention to measurement units. (2) Convert the Excel file into an ASCII file and eliminate any text heading. The remaining ASCII file should include only numbers arranged in the form of columns and rows with no number “holes.” You should open the excel file and save it as a “.txt” file. Then delete the title and statements before the data. Save the file in your work directory of Matlab. (3) Import the ASCII file into Matlab. Do so by making use of the command “load” load('pressure_temperature_data.txt') (4) Construct separate vectors for time, pressure and temperature. Plot the time records of pressure and temperature side by side using the Matlab plotting function “subplot” time = pressure_temperature_data(:,1); pressure = pressure_temperature_data(:,2); temp = pressure_temperature_data(:,3); figure(1); subplot(2,1,1); plot(time, temp,'b'); title('Plot of Temperature vs time'); xlabel('Time'); ylabel('Temperature'); subplot(2,1,2); plot(time, pressure,'b'); title('Plot of Pressure vs time'); xlabel('Time'); ylabel('Pressure'); if i2 > N i2=N; end navg = i2-i1+1; for j=i1:i2 sumt = sumt + temp(j); sump = sump + pressure(j); end avg_temp(i)=sumt/navg; avg_pressure(i)=sump/navg; end p=p+1; figure(p); subplot(2,1,1); plot(time,avg_temp,'b'); title('Average of temperature vs time - window = 2'); xlabel('Time'); ylabel('Temperature'); subplot(2,1,2); plot(time,avg_pressure,'b'); title('Average of pressure vs time - window = 2'); xlabel('Time'); ylabel('Pressure'); end Pressure
Pressure
Running average of ternperature vs tire - window = 10
28 T T T T
@ 26F 4
FS
&
= 2A 4
=
E ab 4
20 1 L L ! L
3.62 3.625 3.63 3.635 3.64 3.645 3.65
it 4
Running average of meee ve time - window = 10 x10
1500 T T T T T
1000 + 4
S007 4
gO L L L L L
5.62 3.625 3.63 3.635 3.64 3.645 3.66
Time xo"
Average of termperature vs time - window = 100
28 T T T T T
a 257 4
=
z 24 4
&
2
F aol 4
20 1 L L 1 L
5.62 3.625 3.63 3.635 3.64 3.645 3.66
Ti 4
Average of pressure ¥etime - window = 100 x10
4200 7 T T 7 T
1000 + 4
8007 4
BOO F 4
400; 4
200 1 L L L L
5.62 3.625 3.63 3.635 3.64 3.645 3.65
Time a
x10
Pressure
Pressure
Average of teriperature vs time - window = 500
28 T T T T T
@ 26F 4
FS
&
= 2A 4
=
E ab 4
20 1 L L ! L
3.62 3.625 3.63 3.635 3.64 3.645 3.65
it 4
Average of pressure cine - window = 500 x10
1200 T T T T T
1000 + 4
B00 fF 4
600 > 4
4007 4
300 L L L L L
5.62 3.625 3.63 3.635 3.64 3.645 3.66
Time xo"
Average of ternperature vs time - window = 1000
26 T T T T T
2
5 24} 4
=
z
a
5 22} |
2
20 L L L L L
5.62 3.625 3.63 3.635 3.64 3.645 3.66
Ti 4
Average of pressure votime - window = 1000 x10
4200 7 T T 7 T
1000 + 4
8007 4
BOO F 4
400; 4
200 1 L L L L
5.62 3.625 3.63 3.635 3.64 3.645 3.65
Time a
x10