Matlab 第一节 基本操作与矩阵输入

这篇博客介绍了Matlab的基本操作,重点讲解了矩阵的创建、索引、运算及特殊矩阵的相关函数。包括变量定义、特殊变量如ans、eps、NaN和Pi,以及矩阵的索引、拼接和操纵。此外,还提到了一些实用函数,如clc、clear、who和whos,以及矩阵相关的函数如eye、zeros、ones和diag。
摘要由CSDN通过智能技术生成

​​​​​​

2.1 Variables

1.变量在执前不需要声明。

2.大小写的变量不一样。

3.变量不能以数字开头。

2.2 Special Variables

  1. ans
  2. i,j
  3. eps(代表极小数)
  4. NaN(Not a Number,例如x=Inf/Inf)
  5. Pi

1.不要用keyword当作你的function name

答案:1.    d.

2.添加分号(;)就不会显示运算结果

Some Functions

·clc:clear command window display

·clear:remove  all  variables in the workspace

·who:variables  in the  workspace

·whos:  variable information of the workspace

Matlab 擅长矩阵的运算

2.3 Array (Vector and Matrix)

Row vector:

>> a = [1 2 3 4]

Column vector:

>>b = [1; 2 ; 3 ;4]

2.4 Array Indexing

A(8) >>按照列来数,第8个

A([1 3 5])>>由A(1)  A(3)  A(5)组成的矩阵

A([1 3 5])= 1    31    17

A[(1 3;1 3])>>由A(1)  A(3)  A(1)  A(3)组成的矩阵

     1     31

  1. 3

A([1 3],[1 3])

2.5 Colon Operater(:等差)

>>B=1:5

     1     2     3     4     5

>>B=1:2:5

     1     3     5

>>B=[1:5;2:3:15;-2:0.5:0]

    1.0000    2.0000    3.0000    4.0000    5.0000

    2.0000    5.0000    8.0000   11.0000   14.0000

   -2.0000   -1.5000   -1.0000   -0.5000         0

>> str = 'a':2:'z'

     'acegikmoqsuwy'

2.6 Indexing Using Colon Operator

>>A(3,:) = []

2.7 Array  Concatenation

2.8 Array Manipulation

 

2.9 Some Special Matrix

eye(n): n×n的单位矩阵

zeros(n1,n2):n1×n2的0矩阵

ones(n1,n2): n1×n2的1矩阵

diag():取出对角线上面的元素

2.10 Some Matrix Related Functions

 

 

                  

 

评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值