学校买了matlab怎么使用 如何使用matlab( 二 )


rand生成均匀分布的伪函数,分布在(0~1)
之间
E=(:,:,1)=randn(10,5)
randn生成标准正态分布的伪随机数(均值为
0,方差为1)
E=(:,:,1)=randi(10,5)
randi生成均匀分布的伪随机整数
D=inv(A) Matrix inversion [Non-squ百思特网are
matrix cannot be inverted]
E=zeros(10,5,3) generates ten rows and
five columns with three digits 0 E=(:,:,1) in the matrix command window means a one-dimensional matrix
E=(:,:,1)=rand(10,5)
rand generates a uniformly distributed pseudo function, distributed in (0~1)
between
E=(:,:,1)=randn(10,5)
randn generates pseudorandom numbers from a standard normal distribution (the mean is0, variance is 1)
E=(:,:,1)=randi(10,5)
Randi generates uniformly distributed pseudo-random integers
3元胞数组
元胞数组是MATLAB中特有的一种数据类型,是数组的一种,其内部元素可以是属于不同的数据类型,概念理解上,可以认为它和c语言里面的结构体、c 里面的对象很类似 。元胞数组是matlab中的特色数据类型,它不同于其它数据类型(如字符型,字符数组或者叫字符串,以及一般的算术数据和数组) 。它特有的存取数据方法决定了它的特点,它有给人一种查询信息的感觉,可以逐渐追踪一直到所有的变量全部翻译成基本的数据信息 。它的class函数输出就是cell 。
Cell array is a unique data type in MATLAB. It is a kind of array. Its internal elements can belong to different data types. In terms of conceptual understanding, it can be regarded as very similar to the structure in the C language and the objects in C . similar. Cell array is a characteristic data type in matlab, which is different from other data types (such as character type, character array or string, and general arithmetic data and array). Its unique data access method determines its characteristics. It gives people a feeling of querying information, and it can be tracked gradually until all variables are translated into basic data information. The output of its class function is cell.
设置A=cell(1,6)
Set A=cell(1,6)
A{2}=eye(3) 表示生成3×3的对角线数值为1的单位矩阵
A{2}=eye(3) generates a 3×3 identity matrix with a diagonal value of 1
A{5}=magic(5)
A{5}=magic(5)
magic(n)生成一个n阶幻方,就是把1-n^2排成一个nxn的矩阵,使得矩阵的每行、每列,以及主、副对角线上面的n个数之和都相等(容易证明,这个和等于n*(n^2 1)/2) 。
magic(n) generates a magic square of order n, which is to arrange 1-n^2 into an nxn matrix, so that the sum of n numbers on each row, each column, and the main and sub diagonals of the matrix are equal (It is easy to prove that this sum is equal to n*(n^2 1)/2).
B=A{5} 即A{5}赋值给了B
B=A{5} ie A{5} is assigned to B
04结构体 Structure
Books=struct(’name’,{{Machine Learning’,’Data Mining’}},’price’,[30 40])
( )内的几位结构体,赋值给books
Books=struct(’name’,{{Machine Learning’,’Data Mining’}},’price’,[30 40])
Several structures in (), assigned to books
Books.name 在books中选取name的属性
Books.name select the attribute of name in books
Books.name(1)
Books.name{1}
#
Matlab矩阵操作
Matlab matrix operations
#
1. 矩阵的定义与构造
设置A=[1 2 3 5; 8 5 4 6]
The definition and construction of matrix
Set A=[1 2 3 5; 8 5 4 6]
B=1:2:9
其中1、2分别确定最大值 ,2为步长
B=1:2:9
Among them, 1 and 2 respectively determine the maximum value, and 2 is the step size
C=repmat(B,3,1) 重复
C=repmat(B,3,1)repeat
D=ones(2,4) 表示生成一个2行4列且值均为1的矩阵


以上关于本文的内容,仅作参考!温馨提示:如遇健康、疾病相关的问题,请您及时就医或请专业人士给予相关指导!

「四川龙网」www.sichuanlong.com小编还为您精选了以下内容,希望对您有所帮助: