Python Package from Library Compiler: Matlab Runtime Error: Index exceeds matrix dimensions

落爺英雄遲暮 提交于 2019-12-11 18:29:37

问题


I have a function in Matlab. I created a python package from it to use in my python code. So far so good. When i call the function in python i received the message:

MatlabRuntimeError: An error occurred when evaluating the result from a function. Details: File C:\Users\Roberto\AppData\Local\Temp\Guilherme\mcrCache9.0.1\classi4\classificado\contagemWGS84.m, line 59, in contagemWGS84 Index exceeds matrix dimensions.

when i go to the line 59 of my code:

plantas(1) = dados{1}(1);  %line 59
plantas(1).Diameter = ...
    2*sqrt((dados{1}(1).Area*res^2)/pi) + 2*step_erode(1)*res;
for i=1:length(dados)
...
...
...

where dados is an 8x1 struct, dados{1} is a 99x1 struct, and dados{1}(1) is a 1x1 struct matrix and numeric fields. When i run the exact same code directy in matlab, it runs with no problem. When i run in python i got this error.

I am using python 2.7 and Matlab R2016a. Please help.


回答1:


Python (and most numpy) arrays are zero indexed so accessing memeber[1][1] of a 1x1 matrix is asking for the second column of the second row.



来源:https://stackoverflow.com/questions/52155425/python-package-from-library-compiler-matlab-runtime-error-index-exceeds-matrix

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!