程序師世界是廣大編程愛好者互助、分享、學習的平台,程序師世界有你更精彩!
首頁
編程語言
C語言|JAVA編程
Python編程
網頁編程
ASP編程|PHP編程
JSP編程
數據庫知識
MYSQL數據庫|SqlServer數據庫
Oracle數據庫|DB2數據庫
您现在的位置: 程式師世界 >> 編程語言 >  >> 更多編程語言 >> Python

MATLAB and python joint programming bug solving: error using double cannot be removed from py List is converted to double.

編輯:Python

I learned a little Matlab and Python Joint programming of , Need to be in Matlab Use in Python list Variable , The reference routine given says that you want to return the data Python list convert to Matlab Of double array

tempForecast = double(forecast.temp)

among forecast.temp It's the temperature forecast , It's a Python Of list type , Use double The function wants to convert , However, the following error messages will appear :

terms of settlement :

According to the official documents , Consider using it first cell Into a cellular array , And then use cellfun Conduct array( matrix ) Transformation of form . The specific code is as follows :

temp=cell(forecast.temp);
tempForecast = cellfun(@double,temp)

So there's no mistake .

Allied , If it is string Type to be converted :

current_time=cell(forecast.current_time)
T=cellfun(@string, current_time)

cellfun Change the first parameter of the function to the type to be converted string That's all right. .

Make a note of , It may be useful in the future .

Reference material
[1] stay MATLAB Use in Python list Variable


  1. 上一篇文章:
  2. 下一篇文章:
Copyright © 程式師世界 All Rights Reserved