时间t(变量)
theta=t+i/9 i=(1~9)
矩阵A=【theta1,theta2,theta3···theta9】
矩阵B=矩阵A内的数除以2*pi的余数
就是这个大概的意思
私信你了
theta1 是一个数,还是一个9个数的list?
import math
def ma2b(t):
a=[t+i/9 for i in range(1,10)]
b=[j%(2*math.pi) for j in a]
return b
import numpy as np
from math import pi
def fun(t):
list_a = [t+i/9.0 for i in range(1,10)]
array_a = np.array(list_a)
print(array_a%(2*pi))
return array_a%(2*pi)
fun(1)
怎么都没有求余数的呢
返回的b 就是余数啊,python里% 就是取余数
%这个符号就是求余数的意思
捅咕出来了
还有个问题 就是 a=[1 if ( theta>1.02 and theta<1.06 )else 0 for theta in theta] 这个代码错了 就是 在theta 处于1.02到1.06之间为1,不在为0. 得到这个a的矩阵
a=[1 if ( i>1.02 and i<1.06 ) else 0 for i in theta] ##这样吧
这个a 是矩阵的形式吗?
[1,2,3,4,5,6] 就是这种形式的
a=[1 if ( theta>phi-phid and theta<phi+phid )else 0 for i in theta]这个错误 TypeError: 'function' object is not iterable
a=[1 if ( i>phi-phid and i<phi+phid ) else 0 for i in theta] ##是前面的也是 i,不是theta
能留个联系方式吗 我这还有一些其他的简单问题 能帮我解决的话,我csdn里充的100都归您