numpy matplotlib 小白教程

NumPy包含array类和Matrix类:
注意MATLAB使用基于1的索引,而python使用基于0的索引。具体参见https://www.numpy.org.cn/user_guide/numpy_for_matlab_users.html
numpy matplotlib 小白教程
numpy matplotlib 小白教程
numpy matplotlib 小白教程
numpy matplotlib 小白教程
numpy matplotlib 小白教程
数据的形状(5, )表示是一个包含5个元素的数组。

初始化数组的方法:
numpy matplotlib 小白教程numpy matplotlib 小白教程numpy matplotlib 小白教程numpy matplotlib 小白教程
数组的索引与切片([ ]里面两个参数,分别行与列;最多两个冒号,分别表示始,末(不包括),步长):
numpy matplotlib 小白教程numpy matplotlib 小白教程(x [0,2] = x [0] [2], 但是第二种情况效率更低)
numpy matplotlib 小白教程
numpy matplotlib 小白教程numpy matplotlib 小白教程

数组的运算:
numpy matplotlib 小白教程
花式索引:直接索引元素 / 整数数组索引 fancy indexing
一维:
numpy matplotlib 小白教程numpy matplotlib 小白教程numpy matplotlib 小白教程
numpy matplotlib 小白教程
二维:(两种方式)
numpy matplotlib 小白教程numpy matplotlib 小白教程
缺省索引:
numpy matplotlib 小白教程
where函数:
numpy matplotlib 小白教程
布尔数组索引:用括号()表示索引
numpy matplotlib 小白教程
索引与切片混合使用??????:
numpy matplotlib 小白教程
数组的运算:
求和sum函数:numpy matplotlib 小白教程
axis=0表示列相加,axis=1表示行相加。
转置.T:numpy matplotlib 小白教程
广播:
numpy matplotlib 小白教程的快速实现版本:向矩阵x的每一行添加向量v相当于通过垂直堆叠多个v副本来形成矩阵vv,然后求x与vv的和(即tile方法):
numpy matplotlib 小白教程
实现广播如下:(如果两个数组在维度上具有相同的大小,或者如果其中一个数组在该维度中的大小为1,则称这两个数组在维度上是兼容的)numpy matplotlib 小白教程

matplotlib:
numpy matplotlib 小白教程
numpy matplotlib 小白教程
子图: plt.subplot(‘行’, ‘列’, ‘编号’)
numpy matplotlib 小白教程
图片:
numpy matplotlib 小白教程