Matlab 与python 部分函数说明

1、reshape:

python 用法:

>> mat = [1:12]

mat =

     1     2     3     4     5     6     7     8     9    10    11    12

>> reshape(mat,[3,4])

ans =

     1     4     7    10
     2     5     8    11
     3     6     9    12

matlab 用法:

A =
    1    4    7    10
    2    5    8    11
    3    6    9    12

B = reshape(A,2,6)

B =
    1    3    5    7    9   11
    2    4    6    8   10   12

注意,python的reshape()函数是第一行开始取行元素来填充reshape后的新矩阵的行元素,不够的话再取下一行,而matlab的reshape()则相反。

2、imshow

python :

cv.imshow()

matlab:

语法:imshow ( f, G) 
      imshow (f, [low high])
      imshow (f, [ ])
说明:G是显示该图像的灰度级数;
      小于或等于low的值都显示为黑色,大于或等于high的值都显示为白色。
       [ ]自动将变量low设置为f的最小值,将high设置为f的最大值。

参考链接:

[1] python和matlab中reshape函数的区别

[2]  https://www.ilovematlab.cn/thread-53545-1-1.html

 

猜你喜欢

转载自blog.csdn.net/ljh618625/article/details/107367430