Python code in MATLAB
2 views (last 30 days)
Show older comments
File name HBMtrail.py
import jos3
import pandas as pd
import numpy as np
class HBM():
def __init__(self,To = np.ones(60), RH = np.ones(60), Va = np.ones(60), no_steps=60):
self._no_steps = no_steps
self._To = To
self._RH = RH
self._Va = Va
def joshbm(self ):
model = jos3.JOS3(height = 1.71, weight = 74, age = 23)
no_steps = self._no_steps
To = self._To
RH = self._RH
Va = self._Va
for i in range(no_steps):
model.To = To[i]
model.RH = RH[i]
model.Va = Va[i]
model.simulate(1)
res = model.dict_results()
df = pd.DataFrame(res)
valid_res = df[df.columns[4:21]]
final_res = valid_res.tail(1)
final_res = final_res.values.tolist()
final_res = final_res[0]
return final_res
The above is the python code and I want this function to be exected in MATLAB
model = py.HBMtrail.HBM(To = [20,21,22],RH = [40,50,60],Va = [0.1,0.2,0.3], no_steps = 3).joshbm()
when I tried the above code in MATLAB I was getting the follwing error
Python Error: TypeError: __init__() takes from 1 to 5 positional arguments but 9 were given
But when I run the same code in python I code runs perfectly fine what should I do?
0 Comments
Answers (1)
Yongjian Feng
on 1 Jul 2021
You want to use python list as input arguments. Try
model = py.HBMtrail.HBM(To = {20,21,22},RH = {40,50,60},Va = {0.1,0.2,0.3}, no_steps = 3).joshbm()
0 Comments
See Also
Categories
Find more on Call Python from MATLAB in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!