フィルターのクリア

n=double(ans) Error using double Conversion to double from py.numpy.ndarray is not possible.

45 ビュー (過去 30 日間)
giacomo labbri
giacomo labbri 2020 年 11 月 12 日
回答済み: Michael Loibl 2021 年 12 月 7 日
Hi,
I am calling a python function from matlab and I get back a ndarray. I try to convert it to a matlab array using double() but i get an error even if I have Matlab 2018b
n=double(ans)
where ans is my ndarray. I get this error:
"Error using double
Conversion to double from py.numpy.ndarray is not possible."
Any idea why it doesn't work or if there is an alternative way to convert ndarray in matlab array?
Thansk in advance,
Giacomo
For reference the output of details(ans) is this:
py.numpy.ndarray handle with properties:
T: [1×1 py.numpy.ndarray]
base: [1×1 py.NoneType]
ctypes: [1×1 py.numpy.core._internal._ctypes]
data: [1×1 py.memoryview]
dtype: [1×1 py.numpy.dtype]
flags: [1×1 py.numpy.flagsobj]
flat: [1×1 py.numpy.flatiter]
imag: [1×1 py.numpy.ndarray]
itemsize: [1×1 py.int]
nbytes: [1×1 py.int]
ndim: [1×1 py.int]
real: [1×1 py.numpy.ndarray]
shape: [1×1 py.tuple]
size: [1×1 py.int]
strides: [1×1 py.tuple]
Methods, Events, Superclasses

回答 (1 件)

Michael Loibl
Michael Loibl 2021 年 12 月 7 日
I just answered a similar question here. It is a general solution, but it might help some people.

カテゴリ

Help Center および File ExchangeCall Python from MATLAB についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by