Skip to content Skip to sidebar Skip to footer

Return Variables From Python To Matlab

I'm trying to pass some variables from python to Matlab, but I didn't manage. If I pass only one variable it works fine, but since I need to pass more variables with different type

Solution 1:

Your function returns a tuple:

>> p = py.file_return.run_test_return;
>> class(p)
py.tuple

and the elements in the tuple are of different data types:

>> class(p{1})
py.numpy.ndarray

>> class(p{3})
py.int

in MATLAB, you can simply wrap the tuple in a cell and iterate over it with cellfun to convert every element to a cell array of doubles:

>> c=cellfun(@double,cell(p),'UniformOutput',false);

Post a Comment for "Return Variables From Python To Matlab"