库编译器的Python软件包:Matlab运行时错误:索引超出矩阵尺寸 [英] Python Package from Library Compiler: Matlab Runtime Error: Index exceeds matrix dimensions

查看:122
本文介绍了库编译器的Python软件包:Matlab运行时错误:索引超出矩阵尺寸的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在Matlab中有一个功能.我从中创建了一个python包,用于我的python代码中.到目前为止,一切都很好.当我在python中调用函数时,收到消息:

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:评估函数结果时发生错误.细节: 文件C:\ Users \ Roberto \ AppData \ Local \ Temp \ Guilherme \ mcrCache9.0.1 \ classi4 \ classificado \ contagemWGS84.m,第59行,在contagemWGS84中 索引超出矩阵尺寸.

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.

当我转到代码的第59行时:

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)
...
...
...

其中dados是8x1结构,dados {1}是99x1结构,dados {1}(1)是1x1结构矩阵和数字字段.当我直接在Matlab中运行完全相同的代码时,它运行没有问题.当我在python中运行时,出现此错误.

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.

我正在使用python 2.7和Matlab R2016a. 请帮忙.

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

推荐答案

Python(和大多数numpy)数组的索引为,因此访问1x1矩阵的memeber [1] [1]要求 second 行的 second 列.

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.

这篇关于库编译器的Python软件包:Matlab运行时错误:索引超出矩阵尺寸的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆