MATLAB Programming
MATLAB Programming MATLAB Programming
7 Working with Scientific Data Formats data 24x5 14784 cell data_combined 1x5 2364 cell var_time 24x1 4608 cell Representing CDF Time Values CDF represents time differently than MATLAB. CDF represents date and time as the number of milliseconds since 1-Jan-0000. This is called an epoch in CDF terminology. MATLAB represents date and time as a serial date number, which is the number of days since 0-Jan-0000. To represent CDF dates, MATLAB uses an object called a CDF epoch object. To access the time information in a CDF object, use the object’s todatenum method. For example, this code extracts the date information from a CDF epoch object: 1 Extract the date information from the CDF epoch object returned in the cell array data (see “Importing Data from a CDF File” on page 7-3). Use the todatenum method of the CDF epoch object to get the date information, which is returned as a MATLAB serial date number. m_date = todatenum(data{1}); 2 View the MATLAB serial date number as a string. datestr(m_date) ans = 01-Jan-2001 Exporting Data to a CDF File To export data from the MATLAB workspace to a CDF file, use the cdfwrite function. Using this function, you can write variables and attributes to the file, specifying their names and associated values. See the cdfwrite reference page for more information. ThisexampleshowshowtowritedateinformationtoaCDFfile. Notehow the example uses the CDF epoch object constructor, cdfepoch, toconverta MATLAB serial date number into a CDF epoch. cdfwrite('myfile',{'Time_val',cdfepoch(now)}); 7-6
Common Data Format (CDF) Files You can convert a cdfepoch object back into a MATLAB serial date number with the todatenum function. 7-7
- Page 518 and 519: 6 Data Import and Export A = dlmrea
- Page 520 and 521: 6 Data Import and Export number of
- Page 522 and 523: 6 Data Import and Export Exporting
- Page 524 and 525: 6 Data Import and Export A = [ 1 2
- Page 526 and 527: 6 Data Import and Export diary off
- Page 528 and 529: 6 Data Import and Export Importing
- Page 530 and 531: 6 Data Import and Export Working wi
- Page 532 and 533: 6 Data Import and Export Exporting
- Page 534 and 535: 6 Data Import and Export 3 Close th
- Page 536 and 537: 6 Data Import and Export type = Mic
- Page 538 and 539: 6 Data Import and Export ndata = xl
- Page 540 and 541: 6 Data Import and Export 41 42 43 4
- Page 542 and 543: 6 Data Import and Export Note While
- Page 544 and 545: 6 Data Import and Export Use these
- Page 546 and 547: 6 Data Import and Export Writing Bi
- Page 548 and 549: 6 Data Import and Export The act of
- Page 550 and 551: 6 Data Import and Export Conversion
- Page 552 and 553: 6 Data Import and Export • Two sp
- Page 554 and 555: 6 Data Import and Export Exchanging
- Page 556 and 557: 6 Data Import and Export urlread('h
- Page 558 and 559: 6 Data Import and Export Once you h
- Page 560 and 561: 6 Data Import and Export For exampl
- Page 562 and 563: 6 Data Import and Export 6-124
- Page 564 and 565: 7 Working with Scientific Data Form
- Page 566 and 567: 7 Working with Scientific Data Form
- Page 570 and 571: 7 Working with Scientific Data Form
- Page 572 and 573: 7 Working with Scientific Data Form
- Page 574 and 575: 7 Working with Scientific Data Form
- Page 576 and 577: 7 Working with Scientific Data Form
- Page 578 and 579: 7 Working with Scientific Data Form
- Page 580 and 581: 7 Working with Scientific Data Form
- Page 582 and 583: 7 Working with Scientific Data Form
- Page 584 and 585: 7 Working with Scientific Data Form
- Page 586 and 587: 7 Working with Scientific Data Form
- Page 588 and 589: 7 Working with Scientific Data Form
- Page 590 and 591: 7 Working with Scientific Data Form
- Page 592 and 593: 7 Working with Scientific Data Form
- Page 594 and 595: 7 Working with Scientific Data Form
- Page 596 and 597: 7 Working with Scientific Data Form
- Page 598 and 599: 7 Working with Scientific Data Form
- Page 600 and 601: 7 Working with Scientific Data Form
- Page 602 and 603: 7 Working with Scientific Data Form
- Page 604 and 605: 7 Working with Scientific Data Form
- Page 606 and 607: 7 Working with Scientific Data Form
- Page 608 and 609: 7 Working with Scientific Data Form
- Page 610 and 611: 7 Working with Scientific Data Form
- Page 612 and 613: 7 Working with Scientific Data Form
- Page 614 and 615: 7 Working with Scientific Data Form
- Page 616 and 617: 7 Working with Scientific Data Form
Common Data Format (CDF) Files<br />
You can convert a cdfepoch object back into a <strong>MATLAB</strong> serial date number<br />
with the todatenum function.<br />
7-7