I am writing a python script from which I hope to call the Matlab anovan function. I have attempted a basic test of this feature on file test.txt.

This file is imported as array data. In matlab, the anovan function would be called as follows:

anovan(data(:,1),{data(:,2),data(:,3)})

In python, I have attempted to call the function like this:

import matlab.engine
eng = matlab.engine.start_matlab()
data = np.genfromtxt('test.txt')
eng.anovan(matlab.double(data[:,0]),matlab.int8(data[:,1:2]))

Unfortunately, this gives the following error:

ValueError: initializer must be a rectangular nested sequence

I can see that there is some issue in passing the last two array columns to the function, but am unsure of the solution. Any suggestions would be appreciated.


I have now worked this out. The issue was in the format of the data passed to the function.

#convert grouping columns to integer lists
list1 = data[:,1].tolist()
for i in range(0,len(list1)):
list1[i] = int(list1[i])
list2 = data[:,2].tolist()
for i in range(0,len(list2)):
list2[i] = int(list2[i])
#The following command now works
eng.anovan(matlab.double(data[:,0].tolist()),[matlab.int8(list1),matlab.int8(list2)])

最新文章

  1. UVA 11768 Lattice Point or Not(扩展欧几里德)
  2. 我所了解的各公司使用的 Ceph 存储集群 (携程、乐视、有云、宝德云、联通等)
  3. 将一个正整数分解为m个2的n次方的和
  4. BZOJ4662 : Snow
  5. HDU 2064 (递推) 汉诺塔III
  6. linux 体系结构知识 博客
  7. POJ 1276 (多重背包) Cash Machine
  8. JAVA 正则表达式 (超详细)
  9. CentOS内核升级
  10. 对称密码-分组密码-AES
  11. #UnityTips# 2017.11.14
  12. GraphicsMagick的命令行使用示例
  13. PTA中提交Python3程序的一些套路
  14. UOJ182 a^-1 + b problem 解题报告
  15. Maven入门教程(一)
  16. [05-02]红帽linux常用操作命令
  17. Java OPC 代码
  18. Codeforces 387E George and Cards
  19. hdu 1043 Eight (八数码问题)【BFS】+【康拓展开】
  20. python实现json转excel

热门文章

  1. python zip压缩文件 并移动到指定目录
  2. Git工具使用
  3. xml与Excel转换
  4. Android 引用文件(.db)的三种方式
  5. 使用webpack将es6 es7转换成es2015
  6. [java初探09]__关于java的包装类
  7. 远程连接服务器或云数据库上的mysql服务 - 赖大大
  8. css3学习--select怎么去掉默认样式
  9. thinkphp通用控制器
  10. js获取带#号链接后的参数