extracting specific data out of big data

5 views (last 30 days)
fadzhi
fadzhi on 15 Nov 2019
Commented: the cyclist on 15 Nov 2019
Dear all,
I have a set of data with first entry being the identifier and starts from 1 to 58769. Each entry has then 4 lines and 8 columns separated by space. I want to extraxt data for a vector like 1,5,9,......Can somebody guide me to achieve this as my skills are limited
Example of data
1 1 3 0 0 0 0 0
0.0 -33.7792 -2.59991 310.8271 42.04916 0.0 0.0 0.0
-0.7746 -33.7792 -2.59991 310.8271 42.04916 0.0 0.0 0.0
0.774597 -33.7792 -2.59991 310.8271 42.04916 0.0 0.0 0.0
2 1 3 0 0 0 0 0
0.0 -33.7792 -2.59991 310.8271 42.04916 0.0 0.0 0.0
-0.7746 -33.7792 -2.59991 310.8271 42.04916 0.0 0.0 0.0
0.774597 -33.7792 -2.59991 310.8271 42.04916 0.0 0.0 0.0
  2 Comments
Guillaume
Guillaume on 15 Nov 2019
Can you attach an example file?
Bob Thompson
Bob Thompson on 15 Nov 2019
What format are you storing the data in currently? My first thought would be to convert the entire thing to a string, and split it into different blocks by identifying the pattern of the first line.
blocks = regexp(fullstring,'.*(\d*\s+1\s+3\s+0\s+0\s+0\s+0\s+0\s*');

Sign in to comment.

Answers (2)

the cyclist
the cyclist on 15 Nov 2019
Your question is not perfectly clear to me, especially regarding
  • the size and shape of your input array(s)
  • the exact output that you want from that input
But if M is an input matrix, then ...
M(1:4:end,:)
will be a matrix that has the 1st, 5th, 9th (and so on) rows, and all the columns.

fadzhi
fadzhi on 15 Nov 2019
I have attached an example of the data which i manually copy pasted (id.851, 853,855,863 and so on). I just want to automate the process, where i provide a list of number to extract from the main data file
Regards,
  1 Comment
the cyclist
the cyclist on 15 Nov 2019
Have you already pulled this text file into MATLAB? If so, can you upload a *.mat file with the data? There are several ways to do that, with potential differences in the resulting variables (e.g. they could be stored as a table, or as a cell array, or as numeric, etc).
And, again, what exactly do you want as the output? One numeric array with all the data? Each id stored separately?
You are leaving too much guesswork for us, which means a higher likelihood that we will provide a solution that does not meet your need.

Sign in to comment.

Categories

Find more on Get Started with MATLAB in Help Center and File Exchange

Products


Release

R2019a

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!