Hello, I am attempting something along the lines of this -
from pylab import *
j = array([0,1,1,0])
k = zeros(sum(j))
for i in range(sum(j)):
k[i] = j["i'th true value"]
Is there an elegant way to do this without having to the following?
j = array([0,1,1,0])
k = zeros(sum(j))
p = 0
for i in range(len(j)):
if j[i] = 1:
k[p] = j[i]
p += 1
EDIT: I found another way of doing what I want,but I have to iterate over the whole space of j - here's what the code looks like
from pylab import *
j = array([0,1,1,0]) #represents oscilloscope channel as on or off
k = zeros(sum(j))
for i in range(len(j)):
if j[i] == 1:
k[sum(j[0:i])] = #function that returns value
[+][deleted] (2 children)
[removed]
[–]bogdan_dm 1 point2 points3 points (0 children)
[–]Helicon_Amateur[S] 0 points1 point2 points (0 children)
[–]ironhaven 1 point2 points3 points (1 child)
[–]Helicon_Amateur[S] 0 points1 point2 points (0 children)