MATLAB Programming

MATLAB Programming MATLAB Programming

cda.psych.uiuc.edu
from cda.psych.uiuc.edu More from this publisher
23.06.2015 Views

6 Data Import and Export was selected, thus generating four row vectors for output: Ann, John, Martin, and Rob. Also, the row vector for John was deselected by clearing the checkbox next to that name in the Wizard. If you run the function, you find that the workspace now holds the four row vectors Ann, John, Martin, andRob, instead of the default variables created by the Import Wizard (data, textdata, androwheaders). Also, note that the vector for John is written to the workspace along with the others, even though this one variable had been deselected from the Import Wizard interface. importfile grades.txt whos Name Size Bytes Class Attributes Ann 1x3 24 double 6-18

Using the Import Wizard John 1x3 24 double Martin 1x3 24 double Rob 1x3 24 double Writing Data to the Workspace To complete the import operation, click Finish to bring the data into the MATLAB workspace. This button also dismisses the Import Wizard. Variables written to the workspace are in one of the following formats. The first three apply only to data read from text files or the clipboard, the fourth applies only to binary files, and the last applies to both: Variable Name data, textdata, rowheaders, colheaders Variables named after row or column headers Single variable named after the filename, or A_pastespecial Variable names taken from binary file Output variable assigned during call to uiimport Output Separate matrices for numeric, text, and header data. One vector for each row or column. One matrix for all data named after the filename Data assigned to each variable stored in a binary file. A single structure having fields that match one of the formats described above. Examples Here are a few examples of how to use the Import Wizard. Example 1—Text Data. Start by creating the text file grades.txt using theMATLABeditor. Thefilecontainsthefollowing: John 85 90 95 Ann 90 92 98 Martin 100 95 97 Rob 77 86 93 6-19

6 Data Import and Export<br />

was selected, thus generating four row vectors for output: Ann, John, Martin,<br />

and Rob. Also, the row vector for John was deselected by clearing the checkbox<br />

next to that name in the Wizard.<br />

If you run the function, you find that the workspace now holds the four row<br />

vectors Ann, John, Martin, andRob, instead of the default variables created by<br />

the Import Wizard (data, textdata, androwheaders). Also, note that the<br />

vector for John is written to the workspace along with the others, even though<br />

this one variable had been deselected from the Import Wizard interface.<br />

importfile grades.txt<br />

whos<br />

Name Size Bytes Class Attributes<br />

Ann 1x3 24 double<br />

6-18

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!