Matlab入门教程
MatlabGetting started
Matlab入门教程.m4a2:09来自LearningYard学苑
Matlab软件介绍
Matlab software introduction
Matlab和Mathematica、Maple并称为三大数学软件 。它在数学类科技应用软件中在数值计算方面首屈一指 。行矩阵运算、绘制函数和数据、实现算法、创建用户界面、连接其他编程语言的程序等 。MATLAB的基本数据单位是矩阵 , 它的指令表达式与数学、工程中常用的形式十分相似 , 故用MATLAB来解算问题要比用C , FORTRAN等语言完成相同的事情简捷得多 , 并且MATLAB也吸收了像Maple等软件的优点 , 使MATLAB成为一个强大的数学软件 。在新的版本中也加入了对C , FORTRAN , C , JAVA的支持 。
Matlab, Mathematica, and Maple are collectively called the three major mathematical software. It is second to none in numerical calculation in mathematical science and technology application software. Row matrix operations, drawing functions and data, implementing algorithms, creating user interfaces, connecting programs in other programming languages, etc. The basic data unit of MATLAB is a matrix. Its instruction expressions are very similar to those commonly used in mathematics and engineering. Therefore, it is much simpler to use MATLAB to solve problems than to use C, FORTRAN and other languages to accomplish the same thing, and MATLAB also Absorbed the advantages of software like Maple, making MATLAB a powerful mathematical software. In the new version, support for C, FORTRAN, C , and JAVA has also been added.
Matlab界面介绍
Matlab interface introduction
1.软件下载完毕后点击“预设”——“字体”更改自己需要的页面设置 。
2.主页中点击“新建”——“脚本” 。新建的脚本就是当前需要编辑的地方 。
3.编辑完成之后按“Ctrl S”进行保存 。
4.清除命令行窗口内容 , 填写“CLC”即可清除工作区内容 , 在命令行窗口填写“clear all” 。
1. After the software is downloaded, click “Preset”-“Font” to change the page settings you need.
2. Click “New”-“Script” on the homepage. The newly created script is the place that needs to be edited currently.
3. After editing, press “Ctrl S” to save.
4. To clear the contents of the command line window, fill in “CLC”, clear the contents of the work area, and fill in “clear all” in the command line window.
Matlab数据类型
Matlab data type
1.字符与字符串
1.Characters and strings
S=’a’ ’ ’中间所表示的所有内容即为字符串
Abs(s) 表示为每个字符都有其对应的ASCII值
Char( ) 表示字符串
Num2str(65) 表示为数字65转换成为’65’
Length(str) 表示为字符串长度【其长度包括空格键】
S=’a’ ’ ’indicates everything in the middle is a string
Abs(s) means that each character has its corresponding ASCII value
Char() represents a string
Num2str(65) is expressed as the number 65 converted into ’65’
Length(str) is expressed as the length of the string [the length includes the space bar]
2.矩阵
Matrix
可用A=[1 2 3;4 5 2;3 2 7]举例
Available A=[1 2 3;4 5 2苏州论坛网苏州论坛网;3 2 7] example
B=A’ 表示矩阵行列将互相变换
B=A’ matrix rows and columns will be transformed into each other
C=A: 表示矩阵将竖拉一排【从第一列开始】
C=A: The matrix will be drawn vertically in one row [starting from the first column]
D=inv(A) 表示矩阵求逆【非方阵无法求逆】
E=zeros(10,5,3) 表示生成十行五列且为三位
的0矩阵命令行窗口中E=(:,:,1)即表示一维矩阵
E=(:,:,1)=rand(10,5)
rand生成均匀分布的伪函数 , 分布在(0~1)
之间
E=(:,:,1)=randn(10,5)
randn生成标准正态分布的伪随机数(均值为
0 , 方差为1)
E=(:,:,1)=randi(10,5)
randi生成均匀分布的伪随机整数
D=inv(A) Matrix inversion [Non-square
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
【学校买了matlab怎么使用 如何使用matlab】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的矩阵
Generate a matrix with 2 rows and 4 columns and the value is 1
矩阵的四则运算
Four arithmetic of matrix
设置A=[1 2 3 4;5 6 7 8]
B=[1 1 2 2;2 2 1 1]
C=A B 表示对应相加
D=A-B 表示对应相减
E=A*B’ B’表示A乘以B的转置 , 且需要确保A行数同B列数相同
F=A.*B 表示对应项相乘
G=A/B 可以理解为G*B=A G*B*pinv(B)=A*pinv(B) G=A*pinv(B)即A*B的逆
Set A=[1 2 3 4;5 6 7 8]
B=[1 1 2 2;2 2 1 1]
C=A B means corresponding addition
D=A-B means corresponding subtraction
E=A*B’ B’ represents the transpose of A multiplied by B, and it is necessary to ensure that the number of rows in A is the same as the number of columns in B
F=A.*B means the corresponding items are multiplied
G=A/B can be understood as G*B=A G*B*pinv(B)=A*pinv(B) G=A*pinv(B) is the inverse of A*B
矩阵的下标 Matrix subscript
设置A=magic(5) Set A=magic(5)
B=A(2 , 3)表示选取第二行 , 第三列
B=A(2,3) means to select the second row and the third column
C=A(3 , :)表示选取第三行的所有列
C=A(3,:) means to select all the columns in the third row
D=A(: , 4)表示选取所有行的第四列
D=A (:, 4) means to select the fourth column of all rows
[m,n]=find(A
推荐阅读
- 88属龙的一生婚姻状况,88年属龙人33岁后命运
- 固态硬盘和机械硬盘的区别 教你区分固态硬盘和机械硬盘
- 麦克风如何降噪 麦克风降噪的详细方法
- 计算机无法识别usb设备怎么办 电脑老是无法识别usb设备的处理办法
- word文件未保存关闭了怎么恢复 word文件未保存被关闭的恢复方法
- 属兔女的贵人是谁,今天属兔人的贵人是谁
- 打印机能扫描吗?手把手教你使用打印机扫描的方法
- 刚出生的宝宝喝多少牛奶
- 电脑垃圾信息怎么拦截 有效拦截电脑垃圾信息的方法