MATLAB Programming
MATLAB Programming MATLAB Programming
6 Data Import and Export Importing from a File TostarttheWizardanduseafilebrowsertolocatethefiletoimport,useone of the menu options or MATLAB commands shown here: • Select Import Data from the File menu • Type uiimport -file • Type uiimport, andthenclickBrowse If you already know the name of the file to import, use one of the following means to initiate the operation: • In the Current Directory browser, right-click the filename and select Import Data • Type uiimport filename, wherefilename is an unquoted string containing the name of the file to import. Importing from the Clipboard To import from the system clipboard, use one of the menu options or MATLAB commands shown here: • Select Paste to Workspace from the Edit menu • Type uiimport -pastespecial • Type uiimport, andthenclickClipboard Importing to a Structure Specifying an output argument with the uiimport command tells MATLAB to return the imported data in the fields of a single structure rather than as separate variables. The command S = uiimport('filename') imports the file filename to the fields of structure S. Thefilename argument is a single-quoted string containing the name of the file to import. 6-10
Using the Import Wizard If you are importing from a binary file, skip ahead to step 4: Determine Assignment to Variables. Previewing Contents of the File or Clipboard [Text only] When the Import Wizard imports text data from a file or the clipboard, it opens the dialog box shown here and displays a portion of the raw data in the preview pane on the left. You can use this display to verify that the file contains the data you expect. Preview of the data in the file. Delimiter found in file. Number of lines of header text ignored. Check this box to generate an M-file function to perform future imports of this type. The pane on the right side of the dialog box shows how MATLAB has assigned the imported data to a default set of variables. The variable names appear in the tabs above the display pane. Click any of these tabs to see the values assigned to that variable. The variable names are derived from categories into which the Import Wizard has sorted the data. These are 6-11
- Page 398 and 399: 4 M-File Programming function [vout
- Page 400 and 401: 4 M-File Programming Running Extern
- Page 402 and 403: 5 Types of Functions Overview of MA
- Page 404 and 405: 5 Types of Functions Note Function
- Page 406 and 407: 5 Types of Functions Arrays of Anon
- Page 408 and 409: 5 Types of Functions Display the da
- Page 410 and 411: 5 Types of Functions If you change
- Page 412 and 413: 5 Types of Functions • “Example
- Page 414 and 415: 5 Types of Functions Supply the val
- Page 416 and 417: 5 Types of Functions Nested Functio
- Page 418 and 419: 5 Types of Functions • From a fun
- Page 420 and 421: 5 Types of Functions not shared bet
- Page 422 and 423: 5 Types of Functions You can now us
- Page 424 and 425: 5 Types of Functions Using a Subfun
- Page 426 and 427: 5 Types of Functions count = 125 22
- Page 428 and 429: 5 Types of Functions shape. The mak
- Page 430 and 431: 5 Types of Functions % FILTFCN. Eac
- Page 432 and 433: 5 Types of Functions 0.6667 filt2(1
- Page 434 and 435: 5 Types of Functions unless you dec
- Page 436 and 437: 5 Types of Functions Accessing Help
- Page 438 and 439: 5 Types of Functions 5-38
- Page 440 and 441: 6 Data Import and Export Working wi
- Page 442 and 443: 6 Data Import and Export • “Dat
- Page 444 and 445: 6 Data Import and Export file that
- Page 446 and 447: 6 Data Import and Export Function r
- Page 450 and 451: 6 Data Import and Export • rowhea
- Page 452 and 453: 6 Data Import and Export File to im
- Page 454 and 455: 6 Data Import and Export Example of
- Page 456 and 457: 6 Data Import and Export was select
- Page 458 and 459: 6 Data Import and Export Import fro
- Page 460 and 461: 6 Data Import and Export File Forma
- Page 462 and 463: 6 Data Import and Export or save ju
- Page 464 and 465: 6 Data Import and Export Data Compr
- Page 466 and 467: 6 Data Import and Export Preference
- Page 468 and 469: 6 Data Import and Export Saving fro
- Page 470 and 471: 6 Data Import and Export Loading Bi
- Page 472 and 473: 6 Data Import and Export Accessing
- Page 474 and 475: 6 Data Import and Export Sharing Me
- Page 476 and 477: 6 Data Import and Export • For sm
- Page 478 and 479: 6 Data Import and Export Note Prope
- Page 480 and 481: 6 Data Import and Export Writable:
- Page 482 and 483: 6 Data Import and Export Ifthefilet
- Page 484 and 485: 6 Data Import and Export For exampl
- Page 486 and 487: 6 Data Import and Export m = memmap
- Page 488 and 489: 6 Data Import and Export Mapping of
- Page 490 and 491: 6 Data Import and Export Repeating
- Page 492 and 493: 6 Data Import and Export Note To su
- Page 494 and 495: 6 Data Import and Export d = m.Data
- Page 496 and 497: 6 Data Import and Export ans = 166x
6 Data Import and Export<br />
Importing from a File<br />
TostarttheWizardanduseafilebrowsertolocatethefiletoimport,useone<br />
of the menu options or <strong>MATLAB</strong> commands shown here:<br />
• Select Import Data from the File menu<br />
• Type uiimport -file<br />
• Type uiimport, andthenclickBrowse<br />
If you already know the name of the file to import, use one of the following<br />
means to initiate the operation:<br />
• In the Current Directory browser, right-click the filename and select<br />
Import Data<br />
• Type uiimport filename, wherefilename is an unquoted string<br />
containing the name of the file to import.<br />
Importing from the Clipboard<br />
To import from the system clipboard, use one of the menu options or <strong>MATLAB</strong><br />
commands shown here:<br />
• Select Paste to Workspace from the Edit menu<br />
• Type uiimport -pastespecial<br />
• Type uiimport, andthenclickClipboard<br />
Importing to a Structure<br />
Specifying an output argument with the uiimport command tells <strong>MATLAB</strong><br />
to return the imported data in the fields of a single structure rather than<br />
as separate variables.<br />
The command<br />
S = uiimport('filename')<br />
imports the file filename to the fields of structure S. Thefilename argument<br />
is a single-quoted string containing the name of the file to import.<br />
6-10