您的位置:首页 > 编程语言 > MATLAB

basic knowledge of MATLAB

2017-10-14 11:02 330 查看
MATALB is short for Matrix Laboeratory --which is used for algorithm develoment,data visualization,data analysis and numerical

calculation--including MATLAB,Simulink and dozens of professional toolboxes.

The basic dta unit of MATLAB is matrix.

DATA TYPE

MATLAB includes 15 basic data types,they are eight kinds od integer,single,double,logical,char,cell,struct and function_handle.

double is the default data type

8-bit unsigned integer

floating-point number: single and double

We can get the range of integer by 'intmin()' and 'intmax' ;

we can get the range of floating-point numer by 'realmin()' and 'realmax()'

stucture node(结构体类型)

MATLAB 中的结构体类似于C语言的结构体数据结构。结构体是按照成员变量名组织起来的饿不同数据类型数据的集合。每个成员变量用指针操作符“.”表示。

函数struct():采用函数struct()产生结构体变量,该函数的调用格式为:S=struct('field1',values1,'field2',values2,....),其中field1和field2等为成员变量名,value1和value2等成员变量的具体值。

cell arry(单元数组)

Cell arry is a special data type,and each of it's elements exists as cell.

Using {} or function cell() to build a cell arry.

Function:

(a) cell():to generate a cell arry

cell(N) generate an N× N empty cell arry.

cell(M,N) or cell([M,N])

cell(M,N,P,...)

cell(size()):to generate a cell arry which has the same dimension with A.

(b) celldisp(): to display the content of the cell arry

celldisp(C)

celldisp(C,'name'):use 'name' to display the content of C

(c) cellplot():use color graphics to display the structure of a cell arry

H=cellplot(c):return is a vector which embodies surface,line and handle(句柄)

H=cellplot(c,,'legend'):add note'legend' to the figure

(d) iscell():to judge whether a variable is cell arry or not

(e) cell2struct() and num2cell

S=cell2struct(C,fields,dim) :transform a cell arry C into structure variable S which diemention is dim.

C=num2cell(A): transform a numerical matrix A into a cell arry C

operator(运算符)

arithmetic operator(算术运算符)

relational operator(关系运算符):

logical operator(逻辑运算符):and or not xor(逐个元素的逻辑运算)

&& ||(快速逻辑运算)

逐位逻辑运算 函数 bitand(a,b)

bitor(a,b) bitnor(a,b) bitcmp(a,b)逐位逻辑非

date and time

clock(): acquire current date, including year, month,day, hour, minute and second.

date(): acquire current date,return is string,format is dd-mmm-yyyy

now(): return current date expressing with double

calendar()
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: