Indexing Python "ndarray" Data in Matlab Prior to Data Conversion

11 次查看(过去 30 天)
I am using R2016b (important for python to matlab functionality). I would like to index into a into a large numpy ndarray and pull the data I specifically need before I convert it to matlab data, because the conversion from python to matlab can be slow and cumbersome for large amounts of data. However, with everything I try I keep getting variations of the following error:
Array formation and parentheses-style indexing with objects of class 'py.numpy.ndarray' is not allowed. Use objects of class
'py.numpy.ndarray' only as scalars or use a cell array.
Can't post my exact code, but lets say I have:
ndarray1 1x1 ndarray
Row_IDs 16x1 double
The 'Row_IDs' are a list of rows within 'ndarray1' that I would like to pull all of the data from. How would I go about doing this? Up until now, I have been using the 'ndarray2mat' function to convert the data first and then pull what I need, but I would really prefer to trim it down to what I need first and then use the 'ndarray2mat' as what I am doing now is too computational expensive. If something isn't clear let me know and I will provide more info.
I fiddled around with variations of:
results = ndarray1(Row_IDs)
results = ndarray1(Row_IDs,:)
results = ndarray1{Row_IDs}
results = ndarray1[Row_IDs]
Simply because I am not very familiar with python data types and was desperate. Thorough searching through matlab answers and stack exchange has not helped me get to an answer, unfortunately.

回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Call Python from MATLAB 的更多信息

产品


版本

R2016b

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by