Version 4 MAT-File Format



Similar documents
This section describes how LabVIEW stores data in memory for controls, indicators, wires, and other objects.

ECE 0142 Computer Organization. Lecture 3 Floating Point Representations

Instruction Set Architecture (ISA)

Caml Virtual Machine File & data formats Document version: 1.4

Embedded Systems. Review of ANSI C Topics. A Review of ANSI C and Considerations for Embedded C Programming. Basic features of C

Data Storage: Each time you create a variable in memory, a certain amount of memory is allocated for that variable based on its data type (or class).

Storing Measurement Data

Informatica e Sistemi in Tempo Reale

The programming language C. sws1 1

How To Write Portable Programs In C

Number Representation

Motorola 8- and 16-bit Embedded Application Binary Interface (M8/16EABI)

Chapter 7D The Java Virtual Machine

DNA Data and Program Representation. Alexandre David

Divide: Paper & Pencil. Computer Architecture ALU Design : Division and Floating Point. Divide algorithm. DIVIDE HARDWARE Version 1

Name: Class: Date: 9. The compiler ignores all comments they are there strictly for the convenience of anyone reading the program.

Desirable Properties Of An Internet Addressing Scheme

The Answer to the 14 Most Frequently Asked Modbus Questions

2+2 Just type and press enter and the answer comes up ans = 4

Parasolid XT Format Reference April 2008

Pemrograman Dasar. Basic Elements Of Java

HOMEWORK # 2 SOLUTIO

CPU Organization and Assembly Language

The New IoT Standard: Any App for Any Device Using Any Data Format. Mike Weiner Product Manager, Omega DevCloud KORE Telematics

Decimal to Binary Conversion

II-9Importing and Exporting Data

Programming languages C

A White Paper about. MiniSEED for LISS and data compression using Steim1 and Steim2

/* File: blkcopy.c. size_t n

The use of binary codes to represent characters

MS ACCESS DATABASE DATA TYPES

Application Note. Introduction AN2471/D 3/2003. PC Master Software Communication Protocol Specification

SQL Server An Overview

Instruction Set Architecture (ISA) Design. Classification Categories

Advanced Tutorials. Numeric Data In SAS : Guidelines for Storage and Display Paul Gorrell, Social & Scientific Systems, Inc., Silver Spring, MD

Arithmetic in MIPS. Objectives. Instruction. Integer arithmetic. After completing this lab you will:

Computer Architectures

DATA_TYPE Values and Data File Storage Formats

8 Square matrices continued: Determinants

Embedded Programming in C/C++: Lesson-1: Programming Elements and Programming in C

for ECM Titanium) This guide contains a complete explanation of the Driver Maker plug-in, an add-on developed for

Chapter 4: Computer Codes

Bachelors of Computer Application Programming Principle & Algorithm (BCA-S102T)

Application Note AN0008. Data Logging Extension. For. Venus 8 GPS Receiver

Numbering Systems. InThisAppendix...

Fundamentals of Programming

Sample EHG CL and EHG SL10 16-bit Modbus RTU Packet

Raima Database Manager Version 14.0 In-memory Database Engine

Computer Architecture Basics

Computer Architecture Lecture 3: ISA Tradeoffs. Prof. Onur Mutlu Carnegie Mellon University Spring 2013, 1/18/2013

Levent EREN A-306 Office Phone: INTRODUCTION TO DIGITAL LOGIC

Computer Science 281 Binary and Hexadecimal Review

5 Arrays and Pointers

2010/9/19. Binary number system. Binary numbers. Outline. Binary to decimal

Database DB2 Universal Database for iseries Embedded SQL programming

13-1. This chapter explains how to use different objects.

Module 816. File Management in C. M. Campbell 1993 Deakin University

The string of digits in the binary number system represents the quantity

Introduction to SQL for Data Scientists

Binary Number System. 16. Binary Numbers. Base 10 digits: Base 2 digits: 0 1

sqlite driver manual

Section 8.2 Solving a System of Equations Using Matrices (Guassian Elimination)

2011, The McGraw-Hill Companies, Inc. Chapter 3

CS321. Introduction to Numerical Methods

Keywords are identifiers having predefined meanings in C programming language. The list of keywords used in standard C are : unsigned void

2 ASCII TABLE (DOS) 3 ASCII TABLE (Window)

Overview. CISC Developments. RISC Designs. CISC Designs. VAX: Addressing Modes. Digital VAX

To convert an arbitrary power of 2 into its English equivalent, remember the rules of exponential arithmetic:

Operation Count; Numerical Linear Algebra

C++ Language Tutorial

Lecture 11 Doubly Linked Lists & Array of Linked Lists. Doubly Linked Lists

SOLVING LINEAR SYSTEMS

Stacks. Linear data structures

Computer Architecture. Secure communication and encryption.

Procedure Call Standard for the ARM 64-bit Architecture (AArch64)

TMS320C67x FastRTS Library Programmer s Reference

Unsigned Conversions from Decimal or to Decimal and other Number Systems

MATLAB Tutorial. Chapter 6. Writing and calling functions

ENGI E1112 Departmental Project Report: Computer Science/Computer Engineering

1 The Java Virtual Machine

RevoScaleR Speed and Scalability

Streaming Lossless Data Compression Algorithm (SLDC)

Simple Image File Formats

Topics. Introduction. Java History CS 146. Introduction to Programming and Algorithms Module 1. Module Objectives

Instruction Set Architecture. or How to talk to computers if you aren t in Star Trek

APCI-8001, APCI-8008 and CPCI-8004

The Windows Shortcut File Format as reverse-engineered by Jesse Hager Document Version 1.0

1 Abstract Data Types Information Hiding

Simple File Input & Output

w w w. g e o s o f t. c o m

Binary Representation. Number Systems. Base 10, Base 2, Base 16. Positional Notation. Conversion of Any Base to Decimal.

ALLIED PAPER : DISCRETE MATHEMATICS (for B.Sc. Computer Technology & B.Sc. Multimedia and Web Technology)

An Incomplete C++ Primer. University of Wyoming MA 5310

GUI Input and Output. Greg Reese, Ph.D Research Computing Support Group Academic Technology Services Miami University

Binary Adders: Half Adders and Full Adders

Sources: On the Web: Slides will be available on:

HP Service Virtualization

Transcription:

Version 4 MAT-File Format Note This section is taken from the MATLAB V4.2 External Interface Guide, which is no longer available in printed form. This section presents the internal structure of Level 1.0 MAT-files. This information is provided to enable users to read and write MAT-files on machines for which the MAT-file access routine library is not available. It is not needed when using the MAT-file subroutine library to read and write MAT-files, and we strongly advise that you do use the External Interface Library if it is available for all of the machines that you are working with. A MAT-file may contain one or more matrices. The matrices are written sequentially on disk, with the bytes forming a continuous stream. Each matrix starts with a fixed-length 20-byte header that contains information describing certain attributes of the Matrix. The 20-byte header consists of five long (4-byte) integers: Field type Description The t ype flag contains an integer whose decimal digits encode storage information. If the integer is represented as MOPT where M is the thousands digit, O is the hundreds digit, P is the tens digit, and T is the ones digit, then: M indicates the numeric format of binary numbers on the machine that wrote the file. Use this table to determine the number to use for your machine: 0 IEEE Little Endian (PC, 386, 486, DEC Risc) 1 IEEE Big Endian (Macintosh, SPARC, Apollo,SGI, HP 9000/300, other Motorola) 2 VAX D-float 3 VAX G-float 4 Cray 32

Version 4 MAT-File Format O is always 0 (zero) and is reserved for future use. P indicates which format the data is stored in according to the following table: 0 double-precision (64-bit) floating point numbers 1 single-precision (32-bit) floating point numbers 2 32-bit signed integers 3 16-bit signed integers 4 16-bit unsigned integers 5 8-bit unsigned integers The precision used by the s ave command depends on the size and type of each matrix. Matrices with any noninteger entries and matrices with 10,000 or fewer elements are saved in floating point formats requiring 8 bytes per real element. Matrices with all integer entries and more than 10,000 elements are saved in the following formats, requiring fewer bytes per element. Element range Bytes per element [0:255] 1 [0:65535] 2 [-32767:32767] 2 [-2^31+1:2^31-1] 4 other 8 T indicates the matrix type according to the following table: 0 Numeric (Full) matrix 1 Text matrix 2 Sparse matrix Note that the elements of a text matrix are stored as floating point numbers between 0 and 255 representing ASCII-encoded characters. 33

mrows ncols imagf namlen The row dimension contains an integer with the number of rows in the matrix. The column dimension contains an integer with the number of columns in the matrix. The imaginary flag is an integer whose value is either 0 or 1. If 1, then the matrix has an imaginary part. If 0, there is only real data. The name length contains an integer with 1 plus the length of the matrix name. Immediately following the fixed length header is the data whose length is dependent on the variables in the fixed length header: Table 9: MATLAB Version 4 MAT-File Matrix Data Format Field name real imag Description The matrix name consists of namlen ASCII bytes, the last one of which must be a n ull character ( \0 ). Real part of the matrix consists of mrows ncols numbers in the format specified by the P element of the type flag. The data is stored column-wise such that the second column follows the first column, etc. Imaginary part of the matrix, if any. If the imaginary flag imagf is nonzero, the imaginary part of a matrix is placed here. It is stored in the same manner as the real data. This structure is repeated for each matrix stored in the file. The following C language code demonstrates how to write a single matrix to disk in Level 1.0 MAT-file format. #include <stdio.h> main() { typedef struct { long type; long mrows; long ncols; 34

Version 4 MAT-File Format long imagf; long namelen; } Fmatrix; char *pname; double *pr; double *pi; Fmatrix x; int mn; FILE *fp; double real_data = 1.0; double imag_data = 2.0; fp=fopen("mymatfile.mat","wb"); if(fp==null) printf("file could not be opened.\n"); else { pname = "x"; x.type = 1000; x.mrows = 1; x.ncols = 1; x.imagf = 1; x.namelen = 2; pr = &real_data; pi = &imag_data; fwrite(&x,sizeof(fmatrix),1,fp); fwrite(pname, sizeof(char), x.namelen,fp); mn = x.mrows *x.ncols; fwrite(pr,sizeof(double),mn,fp); if(x.imagf) 35

} fwrite(pi,sizeof(double),mn,fp); } fclose(fp); Again, we strongly advise against using this approach, and recommend that you instead use the MAT-file access routines provided in the External Interface Library. You will need to write your own C code as shown above only if you do not have the MAT-file access routines for the particular platform on which you need to read and write MAT-files. 36