根据python中不同的小数范围具有不同方程的数学函数

问题描述 投票:0回答:0

我正在尝试用 python 计算这个方程式。

但是我似乎无法执行逻辑操作,因为必须在 np 中使用数组来创建小数范围。

我想知道是否有另一种方法可以在没有 np 的情况下创建范围,或者是否有另一种方法可以对此执行逻辑。

我还在学习中,希望能帮助解决这个问题,谢谢!

这是我在下面尝试过的。 尽管我收到语法错误。尝试过 np.logical_and 但没有成功。

# Cardiac Elastance and Compliance Calculation

import numpy as np

# Timestep for one cardiac cycle
# Creates from 0 to 1 spaced by 0.02

x = np.linspace(0, 1, num=51)

# Time of ventricular contraction and relaxation

T_vc = 0.25

T_vr = 0.125


#Ventricles 
def vent_elastance(x):
    if x >= 0 and x <= T_vc
        return 0.5 - 0.5 * cos(pi*x/T_vc)
    
    #elif x > T_vc and  x <= (T_vc + T_vr):
        #return 0.5 + 0.5 * cos (pi * (x-T_vc) / T_vr )
    
    #else:
        #return 0

y = vent_elastance(x)
python function
© www.soinside.com 2019 - 2024. All rights reserved.