读取文件并打印特定答案

时间:2017-11-09 12:35:24

标签: python numpy matrix

我读了一个名为<ngx-slider [(ngModel)]="sliderValue" [step]="5" [filled]="true" [min]="10" [max]="200" (mouseup)="sliderEvent()"> </ngx-slider> 的文本文件,其中包含CJ.txt2(z and mub)行。 ((我只写了我的程序的重要部分))。 问题是如何定义或调用“r”来达到合适的答案,例如:我想打印31。它需要r[25]r[25]=mub[25]*z[25]r[i]的另一个i0可以获得与上面类似的内容。

31

或创建数组

from math import *
import numpy as np
from scipy.integrate import quad
from scipy.integrate import odeint
min=l=m=n=b=t=chi=r=None
f=0
z,mub=np.genfromtxt('CJ.txt',unpack=True) # opening the text file

for i in range(len(z)): # This means from 0 to 31
   r[i]=mub[i]*z[i]  # need a function similar to this

   print(r[5],r[31],r[2],r[12]) #and other r

我不知道这个问题容易或困难,但对我来说非常重要。 我感谢你的时间和你的关注。

1 个答案:

答案 0 :(得分:1)

这就是你要找的吗?

z,mub=np.genfromtxt('CJ.txt',unpack=True) # opening the text file
r = []
for i in range(len(z)): # This means from 0 to 31
    r.append(mub[i]*z[i])  # need a function similar to this

print(r[5],r[31],r[2],r[12]) #and other r
相关问题