How can I convert Python list to column vector?
显示 更早的评论
I'm using the fitdist method from MATLAB in Python where x is:

I tried different approaches to work on this and they all give the same error:
eng.fitdist(eng.cell2mat(list(x)), 'stable')
eng.fitdist(matlab.double(list(x)), 'stable')
eng.fitdist(list(x), 'stable')
All of these give me this error:
MatlabExecutionError:
File C:\Program Files\MATLAB\R2020b\toolbox\stats\stats\fitdist.m, line 126, in fitdist X must be a numeric column vector.
Any idea how to get out of it? How do I convert my list to a column vector that works with MATLAB?
I am using MATLAB R2020b
采纳的回答
更多回答(1 个)
Raynier Suresh
2021-2-22
Hi, The input to fitdist must be a column vector, from your image it looks like the input has multiple columns in it. You can pass the list with single column to matlab.double() and then pass it to the fitdist function. You can refer the below code and links for more information.
from sklearn import datasets
import matlab.engine
eng = matlab.engine.start_matlab()
iris = datasets.load_iris()
X = iris.data[:, :1]
print(X)
L = X.tolist()
print(L)
Pd = eng.fitdist(matlab.double(L),'stable')
print(Pd)
类别
在 帮助中心 和 File Exchange 中查找有关 Call MATLAB from Python 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!