extracting specific data out of big data

5 次查看(过去 30 天)
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 个评论
Bob Thompson
Bob Thompson 2019-11-15
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*');

请先登录,再进行评论。

回答(2 个)

the cyclist
the cyclist 2019-11-15
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 2019-11-15
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 个评论
the cyclist
the cyclist 2019-11-15
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.

请先登录,再进行评论。

类别

Help CenterFile Exchange 中查找有关 Workspace Variables and MAT-Files 的更多信息

产品


版本

R2019a

Community Treasure Hunt

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

Start Hunting!

Translated by