How can I convert Python list to column vector?
Ältere Kommentare anzeigen
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
Akzeptierte Antwort
Weitere Antworten (1)
Raynier Suresh
am 22 Feb. 2021
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)
Kategorien
Mehr zu Call MATLAB from Python finden Sie in Hilfe-Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!