octave或matlab实操指令学习

1、ones(2,3) 中的2和3分别指生成的1矩阵是两行三列的矩阵

《octave或matlab实操指令学习》 Paste_Image.png
《octave或matlab实操指令学习》 Paste_Image.png

2、rand( )生成的矩阵中的元素值均匀分布在0到1之间

《octave或matlab实操指令学习》 Paste_Image.png

3、size(A)指矩阵A是几行几列的矩阵

《octave或matlab实操指令学习》 Paste_Image.png

size(A,1)得到矩阵的行数,size(A,2)得到矩阵A的列数

《octave或matlab实操指令学习》 Paste_Image.png

4、who命令显示在工作空间中的文件

《octave或matlab实操指令学习》 Paste_Image.png

而whos命令会给出关于工作空间文件更加详细的信息

《octave或matlab实操指令学习》 Paste_Image.png

5、取出pricey文件中前十个数据

《octave或matlab实操指令学习》 Paste_Image.png

6、把v的值保存到hello.mat中的命令

《octave或matlab实操指令学习》 Paste_Image.png

7、加载数据到工作空间

《octave或matlab实操指令学习》 Paste_Image.png

8、保存可读性更好的数据格式

《octave或matlab实操指令学习》 Paste_Image.png

9、根据索引取值(matlab和octave中的索引值是从1开始的)
《octave或matlab实操指令学习》 Paste_Image.png

10、取矩阵A中第二行的所有元素

《octave或matlab实操指令学习》 Paste_Image.png

取矩阵A中第二列的所有元素

《octave或matlab实操指令学习》 Paste_Image.png

11、取出矩阵中第一行和第三行的所有元素

《octave或matlab实操指令学习》 Paste_Image.png

12、取值之后进行赋值(注意:列与列之间要使用分号)

《octave或matlab实操指令学习》 Paste_Image.png

添加一列到矩阵A中(其中的都好是无关紧要的):

《octave或matlab实操指令学习》 Paste_Image.png

13、将A矩阵转变为向量

《octave或matlab实操指令学习》 Paste_Image.png

14、加分号是指在列方向上连接

《octave或matlab实操指令学习》 Paste_Image.png

15、A.*B是指对应元素相乘

《octave或matlab实操指令学习》 Paste_Image.png
《octave或matlab实操指令学习》 Paste_Image.png
《octave或matlab实操指令学习》 Paste_Image.png

16、使用max()函数时既可以返回矩阵中每一行最大值也可以得到相应列最大值的索引

《octave或matlab实操指令学习》 Paste_Image.png

《octave或matlab实操指令学习》 Paste_Image.png

关于max函数的详细讲解
http://wenku.baidu.com/link?url=dUMA3pjv-JHootfMh_sF5pNcjL4L8XjmmQuw_YCOmfd4bQaB5ZsjEy7EcwM2wEwNbLZLskImo3Hn-JFPYIkQs1MqhiDRjtIibbxn9anwr5O

17、矩阵逻辑运算

《octave或matlab实操指令学习》 Paste_Image.png

18、 magic(3)得到3×3的矩阵,它的每行和每列相加能得到一个相同的值

《octave或matlab实操指令学习》 Paste_Image.png

18、r 代表行索引,c代表列索引

《octave或matlab实操指令学习》 Paste_Image.png

19、取每一列的最大值和取每一行的最大值(1代表列中的比较,2代表行中的比较)

《octave或matlab实操指令学习》 Paste_Image.png

默认情况下返回的是每一列的最大值

《octave或matlab实操指令学习》 Paste_Image.png

20、求矩阵中所有元素的最大值

《octave或matlab实操指令学习》 Paste_Image.png

21、矩阵列元素相加(1代表列,如上)

《octave或matlab实操指令学习》 Paste_Image.png

22、矩阵行中元素相加

《octave或matlab实操指令学习》 Paste_Image.png

23、 矩阵A 求逆用pinv(A)命令

《octave或matlab实操指令学习》 Paste_Image.png

24、hold on命令表示多个图形放在同一个窗口中,xlabel(‘time’)表示对x轴贴上‘time’标签,同理ylabel( ),legen(‘sin’,’cos’)代表sin函数和cos函数的图例,title()是给图像加标题,最后的存储命令是cd ‘c:\users\ang\Desktop’; print -dpng ‘myplot.dpng’
close最后关闭图像

《octave或matlab实操指令学习》 Paste_Image.png
《octave或matlab实操指令学习》 Paste_Image.png

25、subplot(1,2,1)前两个参数指将图像窗口分成1*2个格子,最后的参数1是指在使用第一个格子画图
同理subplot(1,2,2)

《octave或matlab实操指令学习》 Paste_Image.png

26、matlab中的for循环

《octave或matlab实操指令学习》 Paste_Image.png

27 、for i = indices 和for i = 1:10类似,相当于python中的for i in range(1,11)

《octave或matlab实操指令学习》 Paste_Image.png

28、while循环

《octave或matlab实操指令学习》 Paste_Image.png

注意matlab中的缩进语法,每一个代码块必须要有一个end;结尾

《octave或matlab实操指令学习》 Paste_Image.png

29、可以利用addpath(“路径”)来添加octave或者matlab的搜索路径

《octave或matlab实操指令学习》 Paste_Image.png

30、matlab中定义函数

《octave或matlab实操指令学习》 Paste_Image.png

蓝色背景下的y1,y2代表会返回两个值

《octave或matlab实操指令学习》 Paste_Image.png

调用函数的方法
《octave或matlab实操指令学习》 Paste_Image.png

31、求线性回归中的代价函数

《octave或matlab实操指令学习》 Paste_Image.png
《octave或matlab实操指令学习》 Paste_Image.png

注意了:小记一下!

《octave或matlab实操指令学习》 Paste_Image.png
《octave或matlab实操指令学习》 Paste_Image.png
《octave或matlab实操指令学习》 Paste_Image.png

31、梯度下降法的theta系数的更新规则

《octave或matlab实操指令学习》 Paste_Image.png

!!!不知道选择哪个

《octave或matlab实操指令学习》 Paste_Image.png

    原文作者:mugtmag
    原文地址: https://www.jianshu.com/p/015606b04cce
    本文转自网络文章,转载此文章仅为分享知识,如有侵权,请联系博主进行删除。
点赞