Download as doc, pdf, or txt
Download as doc, pdf, or txt
You are on page 1of 2

W.R.

Wilcox, Clarkson University, 2 May 2005

1. Importing data into MATLAB


As an example, you are going to examine data for the
vapor pressure of carbon monoxide.1 Click on Carbon
monoxide vapor pressure data and use File, Save as to
save it to the drive you are using for your MATLAB
files. Open this file using Notepad (Files of all types)
and examine the data. You should see a table of vapor
pressure in Pa versus absolute temperature in K, as
shown to the right as Figure 1.1.
Now you are going to import these data 2 into
MATLAB. Open the Workspace window and click on
the third icon (Load data file) as shown in Figure 1.2
below.3

Figure 1.1. CO vapor pressure data


file as displayed in Notepad.
Figure 1.2. MATLABs Workspace window.
The Load data file icon has a white background.

Open COvapP.dat. This opens MATLABs Import Wizard 4, which displays the CO vapor
pressure data and generates three arrays, as shown on Figure 1.3 on the next page. These arrays
are imported into MATLAB when you click on Next and then Finish. In MATLABs Command
window type:
>> data
to verify that the data have been imported. Also examine the data by double clicking on the data
icon in the Workspace window. This will open the Array Editor. Note that column 1 of data has
the pressure data while column 3 has the temperature data. Close the Array Editor. You are now
ready to plot these data. To proceed, click on 2. Plotting data using MATLAB.

The vapor pressure is the pressure of pure vapor that is in equilibrium with pure liquid. It is a function of
temperature. It has been measured for many important substances and can be found, for example, in The
Handbook of Chemistry and Physics (CRC).
2
Note that data is the plural of the Latin word datum. It is a serious error to write this data or data is.
3
Alternately, click on File, Import Data.
4
See Help, MATLAB Help, Search, Import Wizard for more information. Search for Supported File Formats to see
a list of formats from which data can be loaded into MATLAB, along with alternate commands that can be used for
each in the Command window.
1

Figure 1.3. MATLABs Import Wizard showing the CO vapor


pressure data.

You might also like