且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

替换python中的matlab find函数

更新时间:2022-04-21 02:01:31

虽然顺序和索引条件不同,但两种方法确实提供了相同的答案.

Both methods do provide the same answer, although order and indexing conditions are different.

Python 的数组索引从 0 开始,就像在 C 中一样,而 matlab 的索引从 1 开始.

Python indexing of arrays starts from 0, like in C, whilst matlab's one starts from 1.

此外,两个输出(通过 matlab 和 numpy)确实彼此对应项的排列.这可能是由于不同的索引实现.

Moreover, the two outputs (by matlab and numpy) do correspond one another modulo a permutation of the terms. Likely this is due to different indexing implementations.

您可以看到 matlab 按列遍历矩阵,而 numpy 按行遍历.

You can see that matlab goes through your matrix by columns, while numpy by rows.