Convert Python list Type to MATLAB double
88 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Hello All,
I would like to convert the python list type to matlab double.
I have tried the following,
First approach
out = func.getValues() %python function gives a list of [1,2,...n]
out = cell(out(1:end-1));
out = cellfun(@double,out); %outputs type double
Second approach
out = func.getValues() %python function gives a list of [1,2,...n]
out = func.convlisttoarray(out) %python function imports numpy and converts list to array using numpy.array()
out_double = double(out); % outputs type double
Although the length of the list is 1x150, in both the approaches, Matlab is taking a lot of computation time and the system hangs for a while. This is wierd to me, as a couple of days earlier everything worked fine and it could solve the problem in milli seconds.
Could anyone of you please help me with a faster approach to convert the python list to matlab double?
I am using Matlab 2019b.
Thank you in advance.
Cheers,
Sai Krishna
0 Kommentare
Antworten (1)
Sean de Wolski
am 2 Dez. 2021
q = py.list({1,2,3})
cq = cell(q)
[cq{:}]
2 Kommentare
Sean de Wolski
am 18 Jul. 2022
Do you have python installed and configured? I.e. what's the output of
pyenv
It should not be empty.
Siehe auch
Kategorien
Mehr zu Call Python from MATLAB finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!