Mathematica Skipping numbers in lists in Mathematica

  • Thread starter Thread starter laminatedevildoll
  • Start date Start date
  • Tags Tags
    Mathematica Numbers
Click For Summary
The discussion revolves around using Mathematica to read and manipulate a large dataset containing around 22,000 numbers. The user successfully generated a histogram but seeks to extract every 256th number from the dataset, saving these values under the same name for further analysis. They initially attempted to use the `takedata` function but found it ineffective. After some exploration, they implemented a `Do` loop to skip numbers, but they now face challenges in evaluating the extraction process 256 times for different initial observations (initobs values from 1 to 256). The user is looking for guidance on how to structure the loop correctly to achieve this goal.
laminatedevildoll
Messages
211
Reaction score
0
Hi,

I am new to mathematica, and part of the program I have to write includes reading a file and manipulating the data for research. This file has around 22,000 numbers listed in it. I've already figured out how to look at those numbers and generate a histogram. However, what if I want to skip over numbers, meaning that now I want to read every 256th number until the end of my data set and save it each time under the same name, i.e data1, so I can generate a new histogram with these numbers. I've already tried the takedata option, without much luck.

I'd appreciate any help.
 
Physics news on Phys.org
One simple way to do it would be to write a For [ ] - loop over your data with the appropriate incrementation and writing the operation (the save) in the body of the for-statement.
 
Okay, I figured out how to skip numbers by using a Do loop.

Here's my code so far...

data = BinaryReadList[file,"Integer16"]
lngth = Length[data]
stepsize = 255
numiter = IntegerPart[lngth/stepsize]
initobs=1
data1={}
Do[data1=Append[data1,data[[i]]], {i,initobs,numiter*stepsize,stepsize}]
Readlist[data1]

However, I need to evaluate this 256 times where initobs = 1,2...256. I tried to put this whole expression in a do loop, so that it could output 256 different list for different values of initobs, but it doesn't work. What am I doing wrong?
 

Similar threads

  • · Replies 5 ·
Replies
5
Views
2K
  • · Replies 1 ·
Replies
1
Views
4K
  • · Replies 6 ·
Replies
6
Views
4K
  • · Replies 1 ·
Replies
1
Views
2K
  • · Replies 1 ·
Replies
1
Views
3K
  • · Replies 22 ·
Replies
22
Views
3K
  • · Replies 1 ·
Replies
1
Views
2K
  • · Replies 2 ·
Replies
2
Views
2K
  • · Replies 4 ·
Replies
4
Views
7K
  • · Replies 4 ·
Replies
4
Views
7K