MATLAB程序设计基础

  • 格式:doc
  • 大小:73.50 KB
  • 文档页数:17

下载文档原格式

  / 33
  1. 1、下载文档前请自行甄别文档内容的完整性,平台不提供额外的编辑、内容补充、找答案等附加服务。
  2. 2、"仅部分预览"的文档,不可在线预览部分如存在完整性等问题,可反馈申请退款(可完整预览的文档不适用该条件!)。
  3. 3、如文档侵犯您的权益,请联系客服反馈,我们会尽快为您处理(人工客服工作时间:9:00-18:30)。

第三章MATLAB程序设计基础

chapter 3: Foundation of MATLAB

program design

一、数据及数据文件(Data and Data file)

1. 数据类型:(Data mode)为适应各种不同计算和处理的需求,MATLAB提供了多种数据类型,主要有:

数值数组(Numeric array)—

包括整形(int8,uint8,int16,uint16,int32,uint32)单精度

(signal), 双精度(duble)(MATLAB最常用的变量类型),

稀疏(sparce)数组。按维数分有一维、二维和多维数

组。

Int---Integrate.

Uint---Unsigned Integer data

字符数组(Character array):由字符串组成的数组

单元数组(Cell array):用不同类型和大小的数组组成的数组,同

一个元胞数组中各元胞的内容可以不同。

结构数组(Structure array):与单元数组类似,但其数据的组织能

力更强,更富于变化。

Java类(Java class):由JavaAPI或第三方定义的类函数。

函数句柄(Function handle):可以在一个参数列表中传递,并使

用feval运行.

在工作空间浏览器中不同的数据类型有着不同的图标标识。2. 数据文件(Data file)

MATLAB支持的各种数据文件(Readable file formats of MATLAB)的主要类型及其存取方法如下述:

(1)二进制数据文件:(Binary date file)以.mat为扩展名。是标准的MATLAB数据文件,以二进制编码形式存储。.mat文件可以由MATLAB提供的save和load命令直接存取。

(2)ASCⅡ码数据文件:(ASCⅡcode data file)扩展名为.txt, .dat

等,可以是在MATLAB环境下存储的,也可能是其他软件的计算结果,可以被MATLAB调用,也可以用文本编辑器打开进行观察与修改。可以用save和load命令进行读入和存取。

(3).图象文件:(Graphics file)扩展名为.bmp, .jpg .tif等,用于图形图象处理,可以用imread和imwrite命令进行读入和存取。

(4).声音文件:(Sound file) 扩展名为.wav ,用waveread和wavwrite 命令进行读入和存取。

Readable file formats.

Data formats Command Returns MAT- MATLAB workspace load Variables in file.

CSV- Comma separated numbers csvread Double array.

DAT- Formatted text importdata Double array.

DLM- Delimited text dlmread Double array.

TAB- Tab separated text dlmread Double array. Spreadsheet formats

XLS - Excel worksheet xlsread Double array and cell array.

WK1- Lotus 123 worksheet wk1read Double array and cell array.

Scientific data formats

CDF - Common Data Format cdfread Cell array of CDF

records

FITS- Flexible Image Transport System fitsread Primary or extension table data

HDF - Hierarchical Data Format hdfread HDF or HDF-EOS data set

Movie formats

A VI - Movie aviread MATLA

B movie. Image formats

TIFF - TIFF image imread Truecolor, grayscale or indexed image(s).

PNG - PNG image imread Truecolor, grayscale or indexed image.

HDF - HDF image imread Truecolor or indexed image(s).

BMP - BMP image imread Truecolor or indexed image.

JPEG - JPEG image imread Truecolor or grayscale image.

GIF - GIF image imread Indexed image.

PCX - PCX image imread Indexed image.

XWD - XWD image imread Indexed image.

CUR - Cursor image imread Indexed image.

ICO - Icon image imread Indexed image.

RAS - Sun raster image imread Truecolor or indexed.

PBM - PBM image imread Grayscale image.

PGM - PGM image imread Grayscale image.