MATLAB Programming
MATLAB Programming MATLAB Programming
6 Data Import and Export Import from text file grades.txt, using default variables to store the data: uiimport grades.txt whos Name Size Bytes Class Attributes data 4x3 96 double rowheaders 4x1 272 cell textdata 4x1 272 cell Example 2—Partial Text File with Row Vectors. Import from the same file as in the above example, but this time select Create vectors from each row using row names. Also, clear the checkbox next to variable John so that this one vector does not get written to the workspace: whos Name Size Bytes Class Attributes Ann 1x3 24 double Martin 1x3 24 double Rob 1x3 24 double Example 3—Binary Data Assigned to a Structure. Save numeric and text data in binary format in file importtest.mat and use the Import Wizard toimportthebinaryfileintotheworkspace. C = [1 2 3 4 5;6 7 8 9 10]; D = 'a test string'; save importtest C D clear s = uiimport('importtest.mat') s = C: [2x5 double] D: 'a test string' 6-20
Supported File Formats Supported File Formats The table below shows the file formats that you can read or write from MATLAB along with the functions that support each format. File Format File Content Extension Functions MATLAB formatted Text Extended Markup Language Saved MATLAB workspace .mat load, save Text any textscan Text any textread Delimited text any dlmread, dlmwrite Comma-separated numbers .csv csvread, csvwrite XML-formatted text .xml xmlread, xmlwrite Audio NeXT/SUN sound .au auread, auwrite Microsoft WAVE sound .wav wavread, wavwrite Movie Audio/video .avi aviread Scientific data Spreadsheet Data in Common Data Format Flexible Image Transport System data Data in Hierarchical Data Format .cdf .fits .hdf cdfread, cdfwrite fitsread hdfread Excel worksheet .xls xlsread, xlswrite Lotus 123 worksheet .wk1 wk1read, wk1write 6-21
- 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 448 and 449: 6 Data Import and Export Importing
- 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 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
- Page 498 and 499: 6 Data Import and Export If you hav
- Page 500 and 501: 6 Data Import and Export m.Data(60)
- Page 502 and 503: 6 Data Import and Export m = memmap
- Page 504 and 505: 6 Data Import and Export d = m.Data
- Page 506 and 507: 6 Data Import and Export Data: 1658
Supported File Formats<br />
Supported File Formats<br />
The table below shows the file formats that you can read or write from<br />
<strong>MATLAB</strong> along with the functions that support each format.<br />
File Format File Content Extension Functions<br />
<strong>MATLAB</strong><br />
formatted<br />
Text<br />
Extended<br />
Markup<br />
Language<br />
Saved <strong>MATLAB</strong><br />
workspace<br />
.mat<br />
load, save<br />
Text any textscan<br />
Text any textread<br />
Delimited text any dlmread,<br />
dlmwrite<br />
Comma-separated<br />
numbers<br />
.csv<br />
csvread,<br />
csvwrite<br />
XML-formatted text .xml xmlread,<br />
xmlwrite<br />
Audio<br />
NeXT/SUN sound .au auread,<br />
auwrite<br />
Microsoft WAVE sound .wav wavread,<br />
wavwrite<br />
Movie Audio/video .avi aviread<br />
Scientific data<br />
Spreadsheet<br />
Data in Common Data<br />
Format<br />
Flexible Image Transport<br />
System data<br />
Data in Hierarchical Data<br />
Format<br />
.cdf<br />
.fits<br />
.hdf<br />
cdfread,<br />
cdfwrite<br />
fitsread<br />
hdfread<br />
Excel worksheet .xls xlsread,<br />
xlswrite<br />
Lotus 123 worksheet .wk1 wk1read,<br />
wk1write<br />
6-21